instantsearch icon indicating copy to clipboard operation
instantsearch copied to clipboard

URL parameter can generate an invalid request on Safari

Open speedblue opened this issue 10 years ago • 13 comments

If you open the following page under Safari 9.0.2 (under Mac at least) you will see that there is an invalid query generated: http://service.specialized.com/productfinder/specialized_instantsearch.html?q=&hPP=100&idx=&p=0&is_v=1

The query contains an empty index, this is why the query is invalid (see attached screenshot) screen shot 2015-12-18 at 21 38 29

speedblue avatar Dec 18 '15 20:12 speedblue

FWIW setting options.urlSync.useHash = true seems work better. Still a problem for anyone wanting to use the history API.

dekodesign avatar Dec 23 '15 03:12 dekodesign

Oh, maybe we're trying to read the settings from the URL but failing in Safari, resulting in empty an empty index in the next query.

Not using the hash notation means that we cannot share URI between old and modern browsers. I think we should at least be able to read the URI parameters in Safari, even if we do not use the History API to write them back.

pixelastic avatar Dec 23 '15 09:12 pixelastic

How did this URL was generated?

bobylito avatar Dec 23 '15 10:12 bobylito

In further testing I was able to prevent the issue from happening by explicitly defining options.searchParameters.index. Not sure yet if this might cause any problems with switching indices later on, for example for re-sorting hits.

dekodesign avatar Dec 24 '15 01:12 dekodesign

@dekodesign: By doing so you hardcode the index used for the initial search. This will mitigate the issue, but will not completely fix it. You'll be able to change the currently selected index using the dropdown, but if you then share the url, it will not "remember" the selected index and will always revert to the one hardcoded.

I don't currently have a Mac to reproduce and fix this. I'll have a look start of January.

pixelastic avatar Dec 25 '15 12:12 pixelastic

To complement the issue, here are the step to reproduce :

  • open https://community.algolia.com/instantsearch.js/examples/media/
  • url is updated with infos from the search state (query parameters)
  • in Safari the idx url parameter contains nothing, in the other browsers it contains the name of the currently used index (and this is the expected behavior)

bobylito avatar Jan 04 '16 15:01 bobylito

While running the example locally we don't encounter the issue. Bottom line: can be reproduced with current stable (1.1.0) but not with the dev one (1.2.0-beta). So I suggest to use the beta channel or wait the next release. If this issue can reproduced, I'll reopen this bug.

bobylito avatar Jan 05 '16 10:01 bobylito

I had a report of a similar bug on https://pixelastic.github.io/marvel/ with Safari Mac

image

I've asked more information on the browser

pixelastic avatar Jan 05 '16 16:01 pixelastic

Which version do you use @pixelastic? Can you try 0.12-beta if you're not using it already?

bobylito avatar Jan 06 '16 09:01 bobylito

1.2.0-beta fixed it. We should release it soon. What is blocking us?

pixelastic avatar Jan 06 '16 11:01 pixelastic

Beta were released for magento only not really planned, this will come (1.2). I wonder which commit fixed this, maybe a package update

vvo avatar Jan 06 '16 11:01 vvo

I haven't been able to identify the commit that fixed it so I dunno if we could do a maintenance version. Otherwise we can still release 1.2.0 and then plan 1.3.0 ;)

bobylito avatar Jan 06 '16 13:01 bobylito

It was fixed by 48e843732a2dc855c05aa939f7a37f2bde586e27

vvo avatar Jan 06 '16 18:01 vvo