algolia / instantsearch

โšก๏ธ Libraries for building performant and instant search and recommend experiences with Algolia. Compatible with JavaScript, TypeScript, React and Vue.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/
MIT License
3.66k stars 514 forks source link

Refinement search input resets when a refinement with a different attribute is selected #6277

Open DmitriyMaltsevTakeda opened 1 month ago

DmitriyMaltsevTakeda commented 1 month ago

๐Ÿ› Current behavior

https://github.com/algolia/instantsearch/assets/108726111/c47caa3a-c141-4a9a-b32a-192d7a83d3bc

๐Ÿ” Steps to reproduce

  1. Go to https://codesandbox.io/p/sandbox/hardcore-dawn-nnz68n?file=%2Fsrc%2FApp.tsx
  2. In the first refinement search input ("Search brands") type anything
  3. Observe that the "Brands" facets are now filtered
  4. Select any other refinement with a different attribute, for example, "Appliances" in "Categories"
  5. Observe that the "Brands" facets are reset, even though the refinement search input still has the previous value

Live reproduction

https://codesandbox.io/p/sandbox/hardcore-dawn-nnz68n?file=%2Fsrc%2FApp.tsx

๐Ÿ’ญ Expected behavior

The first refinement facets ("Brands" in this particular example) remain filtered

Package version

instantsearch.js@4.73.1, react-instantsearch@7.12.1

Operating system

macOS Sonoma 14.5

Browser

Chrome 125.0.6422.142

Code of Conduct

Haroenv commented 1 month ago

You could work around this with a custom rendering that calls searchForItems any time there's a query and it renders. It won't do extra requests as it's already done and cached. Would this workaround work for you?

We've considered fixing this in the past but the use case didn't come up often and considered an edge case for now.