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

Modal displays whenever any query string is added to the URL #163

Open
AdamJHall opened this issue Apr 27, 2021 · 0 comments
Open

Modal displays whenever any query string is added to the URL #163

AdamJHall opened this issue Apr 27, 2021 · 0 comments

Comments

@AdamJHall
Copy link

Hello,

We're currently using this library a project and ran into an issue where the search modal would be displayed whenever any query string was added to the URL. This was an issue as any user coming from a marketing email, or google ad would immediately have the search modal pop up.

Our current workaround has been to update the getStateFromUrl function in router.js to filter out any query parameters it shouldn't care about e.g.

export const getStateFromUrl = ({ search }) => {
  let filteredQuery = {};
  if (search) {
    // allowedQueryParams are the only values passed back to the Algolia model
    const allowedQueryParams = [
      'query',
      'refinementList',
      'range',
      'page'
    ];
    const queryString = qs.parse(search.slice(1));
    filteredQuery = Object.fromEntries(
      Object.entries(queryString).filter(([key]) =>
        allowedQueryParams.includes(key)
      )
    );
  }
  return filteredQuery;
};
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

No branches or pull requests

1 participant