Skip to content

Global Search Refactor - Fix Search Debounce

Zack Cuddy requested to merge 345745_03-fix-search-debounce into master

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

  1. Fetch and checkout this branch
  2. Add Feature Flag
  3. Search in the top right very fast and hit enter before 500ms debounce
  4. Ensure the search term is passed to the next page

Debounce

  1. Fetch and checkout this branch
  2. Add Feature Flag
  3. Search in the top right and wait for the debounce
  4. Ensure the records appear
  5. Clear the search
  6. 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.

Merge request reports

Loading