Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(quantic): fix unexpected back browser button behaviour with stand…
…alone search box (#4077) ## [SFINT-5539](https://coveord.atlassian.net/browse/SFINT-5539) There were mainly two issues(issues recorded from the staging package): ## Issue 01: When doing an empty search from the standalone search box, clicking the back button one time would not take you to the home page: https://github.com/coveo/ui-kit/assets/86681870/08461748-bd25-4f0b-8fac-d9592c9f6b54 To solve this issue, I'm simply making the standalone url redirect to `redirectUrl` instead of `redirectUrl?#={query}` when the query is empty. https://github.com/coveo/ui-kit/assets/86681870/e774ffb7-8d12-4415-b208-36f771174269 ## Issue 02: After doing multiple queries and clicking the back button several times, there re situations where SF will disconnect the component and connect it again, disconnecting the component causes the removal for the event listener of hash change which makes the component completely loose control of the changes happening in the URL: https://github.com/coveo/ui-kit/assets/86681870/0d0a5ebf-10f3-4409-a4ae-5adba07e186b To solve this issue, I'm setting `this.initialized` to `false` in the `QuanticSearchInterface` component to make sure we redo the initialization when the component disconnects and reconnect again, the reinitialization would allow adding back the event listener to hash changes so our component will not loose track. Additionally when the component get's connected after being disconnected I'm calling the `synchronize` method to make sure the search parameters are always up to date with what we have in the hash. https://github.com/coveo/ui-kit/assets/86681870/7a0ef4f5-4aef-40d8-b945-493f7151a061 ### Try it yourself: https://momentum-force-3625-dev-ed.scratch.my.site.com/s/ [SFINT-5539]: https://coveord.atlassian.net/browse/SFINT-5539?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Sylvie Allain <[email protected]>
- Loading branch information