Instantsearch.js: urlSync: {mapping: {q: 'query'}} still uses 'q' for query uses both names instead of one

Created on 1 Sep 2017  路  4Comments  路  Source: algolia/instantsearch.js

Do you want to request a feature or report a bug?
Unexpected behaviour (= "bug" from user POV with this usecase)

Bug: What is the current behavior?

When using:

var movies = instantsearch({
  appId: 'latency',
  apiKey: '6be0576ff61c053d5f9a3225e2a90f76',
  indexName: 'movies',
  urlSync: {
    mapping: {
      q: 'query'
    }
  }
});

And the url is: http://test.com/?q=test

Then the searchbox uses "q" AND "query" to infer the current query.

Example: https://codesandbox.io/s/vqm3xmx01y (use urlbar to change to q=test)

Bug: What is the expected behavior?

I am not sure but I would say that only "query" should be read.

Bug: What browsers are impacted? Which versions?

All browser.

Bug: What is the proposed solution?

Only read the mapped query parameters, not the original ones

Feature: What is your use case for such a feature?

Customer use case, he's using "q" to denote its page (like q=about) and so used
mapping but then got bugged because q was still read

What is the version you are using? Always use the latest one before opening a bug issue.

IS V 2

Possible workaround

~For now, using searchFunction + reading the url parameters in the search for "q" can solve it.~ This workaround did not work in the end.

Bug Needs Investigation

Most helpful comment

For contributors:
Impacted support ticked ids:

  • 1106283

All 4 comments

For contributors:
Impacted support ticked ids:

  • 1106283

Another ticket about this issue: 42655 (provokes google caching issue because they use the parameter q).

Previous ticket mentioned by @vvo is 35540

Indeed that's a bug. It should also affect v1, as AFAIK there is no change on this part in v2...

We've released a new system for synchronizing the URL with the search that actually does that and more.

Was this page helpful?
0 / 5 - 0 ratings