Global Search Refactor - Fix Search Debounce
What does this MR do and why?
This addresses a regressions found in Staging: #345745 (comment 752097677)
Work towards #297396 (closed)
This change is behind a feature flag (:new_header_search
)
Feature Flag Rollout Issue: #339348 (closed)
The issue here is caused by the way we debounce the search query on the Header Search. When a user searches we also search the /autocomplete
API to provide some meaningful search options. This needs to be debounced so we don't hit the endpoint with every keystroke.
The issue lies in the fact that until the debounce finishes we don't update the search
model in the store
which then doesn't get passed along if the user hits enter before the debounce runs (500ms).
The change here is to instead immediately update the search term in the store and then debounce the api call itself.
Screenshots or screen recordings
Before | After |
---|---|
Speedy_Searchin | Speedy_Searchin_Fix |
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Speedy Searchin
- Fetch and checkout this branch
- Add Feature Flag
- Search in the top right very fast and hit enter before 500ms debounce
- Ensure the search term is passed to the next page
Debounce
- Fetch and checkout this branch
- Add Feature Flag
- Search in the top right and wait for the debounce
- Ensure the records appear
- Clear the search
- After 500ms search again, ensure the old results are not there
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.