algolia / react-instantsearch

⚡️ Lightning-fast search for React and React Native applications, by Algolia.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/
MIT License
1.97k stars 386 forks source link

Query does clear on reset when using `searchAsYouType` set to `false` in the `<SearchBox>` component #3641

Closed jeremy-dorfschmidt closed 1 year ago

jeremy-dorfschmidt commented 1 year ago

🐛 Bug description

When using the searchAsYouType prop set to false on the <SearchBox> component, clearing the input does not reset the routing/url/clear the search.

🔍 Bug reproduction

Steps to reproduce the behavior:

  1. Ensure the searchAsYouType prop is set to false on the <SearchBox> component
  2. Enter a search term in the search input.
  3. Clear the input using the X in the input
  4. The input is cleared but the routing url/query remains,

Live reproduction:

https://codesandbox.io/s/flamboyant-meitner-gr31yr

💭 Expected behavior

When the reset button (X) is clicked the query should be cleared. The react-instantsearch-hooks-web library should maintain feature set with the non-hooks version.

Environment

Additional Comments

Tracking back a bit this appeared to be an issue in the non hooks version but was corrected via PR 802. I've also noticed that the searchAsYouType prop is fairly new to the hook library..

Haroenv commented 1 year ago

Great catch, thanks! I've just made a pull request that fixes it in https://github.com/algolia/react-instantsearch/pull/3642. Once CI runs as usual you can try it out using the codesandbox instructions that will appear on the pull request.