-
Notifications
You must be signed in to change notification settings - Fork 385
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 Picker: Use searchable dropdown #3027
Comments
Why do we need to to import another library here? There are a couple of autocomplete in gutenberg already.
I wonder if we can use either of them. |
We need a list of all ~1000 fonts that you can scroll through but also filter by typing. These two components don't really allow for that. The suggestion to use |
Isn't there an issue here. If the font picker is a search box, doesn't that require the user to know the name of the font they need? It means users can just browser the fonts they need from a dropdown like google docs or Word. I had a quick look at google docs. See attached screenshots of how it's font selector works. More font options This may not be required, but I thought flag it |
As noted in my previous comment:
So it would not be search-only. Thanks for sharing these screenshots from Google Docs! I took it as an opportunity to see how they load the font previews. Turns out, they just (lazy) load all the fonts, but only with minimum amount of glyphs required. For example, to preview the Slabo 27px font, they basically load |
That is reasonable, yes. Looks like the autocomplete component supports a |
Add here - 5c92430 |
@spacedmonkey Could you please add some testing instructions here for Claudio and then move this to the QA column on the board? Thanks! |
I just ran into something odd:
While I was able to fix some of the errors with the following diff, it still crashes due to an issue in the original diff --git assets/src/stories-editor/components/font-family-picker/autocomplete.js assets/src/stories-editor/components/font-family-picker/autocomplete.js
index b8398ee8..253d8529 100644
--- assets/src/stories-editor/components/font-family-picker/autocomplete.js
+++ assets/src/stories-editor/components/font-family-picker/autocomplete.js
@@ -51,8 +51,8 @@ class Autocomplete extends OriginalAutocomplete {
const inputFocused = focused === -1;
const noOptionsAvailable = options.length === 0;
- const queryNotEmpty = query.length !== 0;
- const queryLongEnough = query.length >= minLength;
+ const queryNotEmpty = query && query.length !== 0;
+ const queryLongEnough = query && query.length >= minLength;
const showNoOptionsFound = this.props.showNoOptionsFound &&
inputFocused && noOptionsAvailable && queryNotEmpty && queryLongEnough;
@@ -84,7 +84,7 @@ class Autocomplete extends OriginalAutocomplete {
<div className={ wrapperClassName } onKeyDown={ this.handleKeyDown } role="combobox" tabIndex="-1" aria-expanded={ menuOpen ? 'true' : 'false' }>
<Status
length={ options.length }
- queryLength={ query.length }
+ queryLength={ query && query.length }
minQueryLength={ minLength }
selectedOption={ this.templateInputValue( options[ selected ] ) }
selectedOptionIndex={ selected } The excessive CSS thing is also very odd thing by itself. It even happens when choosing "Arial" as the custom font. No idea what's going on there. Screenshots (click to expand) |
I have created a PR with some small tweaks that would fix that above error message ^ |
Steps to test.
|
Verified in QA |
Screencast can be seen here. https://youtu.be/D8Yg7Yv4Los ( Same screencast as #3026 ) |
hey folks, is there a reason there's no actual dropdown button, for better (mouse) discoverability? Was this a conscious decision? |
This was a conscious decision. Adding in a dropdown made for a bad user experience. For a number of reasons.
I recommended added an option that show 'Popular Fonts' when user focuses on the input. But UX would need to be designed for this. I didn't do the original do the discovery on this one. I just implied what was on the ticket. |
See #2877 for details.
When we have all these new fonts, we need a better font picker that easily allows scrolling through the hundreds of fonts.
accessible-autocomplete
seems like a good candidate for me, but perhaps there is also a Gutenberg-originating component that we can use.The text was updated successfully, but these errors were encountered: