Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(instantsearch): keep autocomplete in sync with query during navigation #1036

Merged
merged 8 commits into from
Nov 3, 2022

Conversation

dhayab
Copy link
Member

@dhayab dhayab commented Oct 31, 2022

FX-1942

This PR updates autocomplete query to stay in sync with the one in InstantSearch (with routing enabled).

I also changed the templates from strings to html tagged templates, which allowed me to remove preact as a dependency.

We can push the change to the other flavours after we agree on the code for this one.

Preview →

@dhayab dhayab changed the title Docs/instantsearch example query sync docs(instantsearch): keep autocomplete in sync with query during navigation Oct 31, 2022
@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 31, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit ae3b490:

Sandbox Source
@algolia/autocomplete-example-github-repositories-custom-plugin Configuration
@algolia/autocomplete-example-instantsearch Configuration
@algolia/autocomplete-example-playground Configuration
@algolia/autocomplete-example-preview-panel-in-modal Configuration
@algolia/autocomplete-example-react-renderer Configuration
@algolia/autocomplete-example-starter-algolia Configuration
@algolia/autocomplete-example-starter Configuration
@algolia/autocomplete-example-reshape Configuration
@algolia/autocomplete-example-vue Configuration
@algolia/autocomplete-example-instantsearch PR

@dhayab dhayab requested review from a team, FabienMotte and sarahdayan and removed request for a team October 31, 2022 14:25
Copy link
Contributor

@FabienMotte FabienMotte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The query is not synced with this behavior:

Screen.Recording.2022-11-02.at.12.55.11.mov

@dhayab
Copy link
Member Author

dhayab commented Nov 3, 2022

Good find @FabienMotte, this happens because there is no initial pushState (as the state is already set in the URL), so the state isn't available from the popstate event at this time. I've changed the code to retrieve the query directly from instantsearch's helper.

@FabienMotte
Copy link
Contributor

Thanks @dhayab! 👏

Is the sandbox working on your side? Not sure why CodeSandbox is giving a syntax error: https://codesandbox.io/s/github/algolia/autocomplete/tree/docs/instantsearch-example-query-sync/examples/instantsearch

Base automatically changed from docs/make-instantsearch-example-work to next November 3, 2022 09:40
@dhayab dhayab merged commit d0ca975 into next Nov 3, 2022
@dhayab dhayab deleted the docs/instantsearch-example-query-sync branch November 3, 2022 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants