Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

allSearchResults is updated too many times after searching #3407

Closed
ksntcrq opened this issue Mar 30, 2022 · 4 comments
Closed

allSearchResults is updated too many times after searching #3407

ksntcrq opened this issue Mar 30, 2022 · 4 comments

Comments

@ksntcrq
Copy link

ksntcrq commented Mar 30, 2022

🐛 Bug description

When doing a multiple index query with several Index, allSearchResults is updated as many times as there are indices after searching instead of at once.

🔍 Bug reproduction

Steps to reproduce the behavior:

  1. Open the sandbox
  2. Type a letter in the search field
  3. See the console:
  4. Searching becomes true
  5. Searching becomes false and the nbHits of the main index are updated
  6. Only then the nbHits of the other index is updated

Live reproduction:

https://codesandbox.io/s/kind-varahamihira-srcdhn?file=/src/App.js

💭 Expected behavior

I would expect all the nbHits to be updated at the same time, when searching becomes false, because this means that searching is done and that everything was retrieved.

Environment

  • OS: macOS
  • Browser: Chrome
  • Version: 6.23.0

Additional context

I need everything to be updated at once because I need to send a segment event when we're done searching, with the number of results for each index. For this, I'm looking for a searching changing from true to false and need the number of hits to be updated at the same time.

@ksntcrq ksntcrq changed the title allSearchResults state is updated too many times allSearchResults is updated too many times after searching Mar 30, 2022
@dhayab
Copy link
Member

dhayab commented Apr 4, 2022

Hi @ksntcrq , thanks for filing this. It seems like an issue indeed, as searching is set to false as soon as the state is updated with the first index's results.

We're going to look at this, and in the meantime, you can work around this by thoroughly checking that the search parameters are identical in all indices. Here is a sandbox that checks for the query parameter for example: https://codesandbox.io/s/focused-nobel-jiket5?file=/src/App.js.

@ksntcrq
Copy link
Author

ksntcrq commented Apr 5, 2022

@dhayab Thanks!

I see that your Pull Request was already merged. Any ETA on a release?

@Haroenv
Copy link
Contributor

Haroenv commented Apr 5, 2022

It will be released automatically once this PR merges, so in 10-20 minutes, thanks again for reporting! #3421

@ksntcrq
Copy link
Author

ksntcrq commented Apr 5, 2022

Just tried with the new version, I can confirm it's fixed. Thanks!

@Haroenv Haroenv closed this as completed Apr 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants