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

Search box cursor is moved to the end with enabled urlSync #2012

Closed
JanPetr opened this issue Feb 27, 2017 · 5 comments · Fixed by #2013
Closed

Search box cursor is moved to the end with enabled urlSync #2012

JanPetr opened this issue Feb 27, 2017 · 5 comments · Fixed by #2013

Comments

@JanPetr
Copy link
Contributor

JanPetr commented Feb 27, 2017

Do you want to request a feature or report a bug?

Bug

Bug: What is the current behavior?
When the urlSync is enabled, every time URL is updated the cursor is moved to the end of the input field at each key press. So it's nearly impossible to edit query from it's beginning.

Reproduce-able on https://jsfiddle.net/JanPetr/pw2s7zcw/3/ - try to search for "a", then move the cursor on the beginning and add any character. Will see, that the cursor will jump to the end from it's current position.
When you disabled urlSync it works as expected.

The same happens on https://magento.algolia.com/catalogsearch/result/?q=shirt

Related Magento issue - https://github.com/algolia/algoliasearch-magento/issues/774

Bug: What is the expected behavior?
I expect the cursor to stay on the same position.

Bug: What browsers are impacted? Which versions?
At least Google Chrome 56.0.2924.87 (64-bit).
On Firefox 47.0.1 it works OK.

What project are you opening an issue for?

  • instantsearch.js

What is the version you are using? Always use the latest one before opening a bug issue.
https://cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.js

@vvo
Copy link
Contributor

vvo commented Feb 28, 2017

Thx clearly a critical bug, tackling it now

vvo pushed a commit that referenced this issue Feb 28, 2017
The effect was there since the begining but only visible since the move
to "only update url every 700ms". Since you can definitely move the
search box cursor back in 700ms, you would see the input cursor move to
the end of the search box from time to time.

The bug fix is done by ignoring any hashchange event occuring after a
manual url hash update.

fixes #2012
@vvo
Copy link
Contributor

vvo commented Feb 28, 2017

fix incoming

vvo added a commit that referenced this issue Feb 28, 2017
The effect was there since the begining but only visible since the move
to "only update url every 700ms". Since you can definitely move the
search box cursor back in 700ms, you would see the input cursor move to
the end of the search box from time to time.

The bug fix is done by ignoring any hashchange event occuring after a
manual url hash update.

fixes #2012
@vvo
Copy link
Contributor

vvo commented Feb 28, 2017

released as 1.11.2

@vvo vvo closed this as completed Feb 28, 2017
vvo pushed a commit that referenced this issue Feb 28, 2017
<a name="1.11.2"></a>
## [1.11.2](v1.11.1...v1.11.2) (2017-02-28)

### Bug Fixes

* **searchBox:** avoid unwanted cursor jumps on hashchange (#2013) ([d0103db](d0103db)), closes [#2012](#2012)
@SenenLT
Copy link

SenenLT commented Mar 29, 2017

Thanks @Haroenv - we will try this build

@SenenLT
Copy link

SenenLT commented Apr 19, 2017

Works! Thanks Team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants