-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix React combobox debounce #4331
Conversation
6568150
to
7d91706
Compare
|
if (isOpen) { | ||
fetchOptions() | ||
} | ||
}, [search], 200) |
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.
Why is this 200 in one case and 300 in another?
Proposal: Let's unify and make it a exported const somewhere.
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.
Good point, agreed. The 'standard' delay could even be baked in to theuseDebouncedEffect
and not be configurable.
3a8db64
to
5a4152b
Compare
...And define the default delay in the hook
9ee757c
to
7ff870b
Compare
Closed in favor of #4349 |
Changes
In the
PlausibleCombobox
component (used in the filter menus and theprop_key
picker), we're currently making too many API calls to fetch selectable options. Currently, we're calling the API for every keystroke. This PR fixes that - we will only make a request once 200ms has passed from the last keystroke (reusing theuseDebouncedCallback
custom hook introduced in #4318).Also in this PR:
useDebouncedEffect
custom hook to not set a delay for the initial function call. Currently the search in all breakdown modals is waiting 300ms before calling the API for the first time. This fixes that.Tests
Changelog
Documentation
Dark mode