-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Support a more flexible useItems API for the autocompleters API #22853
Conversation
Size Change: -165 B (0%) Total Size: 1.12 MB
ℹ️ View Unchanged
|
I'm fine with this, if it helps. Would be nice to see usage of the hook |
E2e tests that use the slash inserter fail on Travis, I think it's a bad sign 😅 |
I tested it locally and it works perfectly fine in all the cases I tested:
|
d37c1ce
to
73dbcd3
Compare
feb1020
to
5754c4b
Compare
5754c4b
to
2cca698
Compare
The test changes are actually intermittent failures on master too. they are though harder to trigger on master (I was able to do it something though) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on my previous testing 👍
const useItems = autocompleter.useItems | ||
? autocompleter.useItems | ||
: ( filterValue ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we confident now to document useItems
, or is there a reason to wait?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some potential things we may want to add, like a way to show alternative UIs (not just a flat list) but I do feel confident about useItems.
Right now, the autocompleters API is a bit limitted and relies only on global functions to fetch the options. It also doesn't allow us to reuse logic easily: for instance the Inserter use hooks to fetch the available items to insert but these hooks can't be reused inside the autocompleter itself which make it very hard to support things like: block variations, block patterns... without duplicating a lot of logic.
This PR updates the
Autocomplete
component to rely on auseItems
hook in the autocompleter definition. If the hook has not been provided, a default one relying on the existing autocompeters API is used.That component is a bit complex, so potential regressions are not excluded.
As a follow-up I'll be updating the block autocompleter to support patterns and block variations.
Testing instructions