elastic / search-ui

Search UI. Libraries for the fast development of modern, engaging search experiences.
https://docs.elastic.co/search-ui
Apache License 2.0
1.92k stars 368 forks source link

Duplicate search query gets issued by unrelated Axios request #1024

Closed JeroenAdam closed 7 months ago

JeroenAdam commented 7 months ago

In my use case, I'm seeing SearchProvider issue a duplicate search query, triggered by an async XMLHttpRequest (Axios). Those should not be related to eachother but they seem to be.

image

This gets triggered by a user interaction toggling/unfolding (by clicking) a result, I made it so that there is an API call to my application backend (not Elasticsearch). The exit point from Axios is dispatchXhrRequest. The entry point for SearchProvider is the useEffect dependent on config.searchQuery followed by an update of the searchQuery configuration in SearchDriver. If I compare the previous response from Elasticsearch with the duplicate response, they are identitcal.

debug: true shows indeed 'Search UI: State Update' but there is no state update, there only was an Axios XMLHttpRequest. As soon as I get rid of the XMLHttpRequest, the duplicate search query does not get issued.

image

You can see this behavior live, go to the folllowing url and click on a result: https://login.adambahri.com:1112/realms/jhipster/protocol/openid-connect/auth?response_type=code&client_id=web_app&scope=openid%20profile%20email&redirect_uri=https://app.adambahri.com:1114/login&login_hint=user&password=cca86cd5b97b

Backend: Elasticsearch, packages: react-search-ui, search-ui-elasticsearch-connector

joemcelroy commented 7 months ago

looking at your page, i noticed:

I suspect its re-rendering the page and that the clickhandler you have is adding a page in the history every time its being clicked. Check the way you handle the result click and prevent a url transition.

Closing this because I believe its not a bug in search-ui.