Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font Family: consider using CustomSelectControl instead of SelectControl #57301

Open
Tracked by #60528
JuanLucha opened this issue Dec 21, 2023 · 1 comment
Open
Tracked by #60528
Labels
[Feature] Font Library [Feature] Typography Font and typography-related issues and PRs [Type] Enhancement A suggestion for improvement.

Comments

@JuanLucha
Copy link

What problem does this address?

The Font Family in Typography is one of the dropdown fields the user can find in the sidebar. This field uses the SelectControl component to display the font families for the user to select one. This component is a wrapper of the <select> HTML element. Each browser shows the dropdown in its own way, as it is part of the <select> element managed by the browser.

Here is an example of when the field holds a lot of fonts (like Google Fonts, for example):

  • Firefox:
Screenshot 2023-12-21 at 09 56 38
  • Chrome:
Screenshot 2023-12-21 at 09 57 40

When scrolling over the options, firefox scrolls inside the dropdown without changing its top position, but in Chrome, that scrolling makes the dropdown grow to the height of the screen:
Screenshot 2023-12-21 at 09 57 52

What is your proposed solution?

We should consider using CustomSelectControl instead of SelectControl. We are already using that for other fields, like the Font Size:
Screenshot 2023-12-21 at 09 56 01

Using that component would maintain the same appearance and behavior among different browsers, including the vertical scroll behavior we could see in Chrome.

@JuanLucha JuanLucha added the [Type] Enhancement A suggestion for improvement. label Dec 21, 2023
@jordesign jordesign added the [Feature] Typography Font and typography-related issues and PRs label Dec 21, 2023
Utsav-Ladani added a commit to Utsav-Ladani/gutenberg that referenced this issue Dec 28, 2023
When we have too many fonts, SelectControl shows font list whose height is equal to screen height in the Chrome. But in Firefox height is not that much larger.

SelectControl uses default HTML select interface, however CustomSelectControl uses custom interface, so user can see scrollable list instead of taller list. This way we can enhacne the UI

Fixes WordPress#57301.
@Utsav-Ladani
Copy link

Hey @JuanLucha @jordesign, I replace the component to achieve the same UI across all different browsers in this PR. Please let me know if we can make any further enhancements.

Utsav-Ladani added a commit to Utsav-Ladani/gutenberg that referenced this issue Jul 28, 2024
When we have too many fonts, SelectControl shows font list whose height is equal to screen height in the Chrome. But in Firefox height is not that much larger.

SelectControl uses default HTML select interface, however CustomSelectControl uses custom interface, so user can see scrollable list instead of taller list. This way we can enhacne the UI

Fixes WordPress#57301.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Font Library [Feature] Typography Font and typography-related issues and PRs [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants