Closed ILiuz closed 3 months ago
Thanks @ILiuz. v0.2.5 was just released yesterday. Just to help narrow things down, did you experience this before that release? (Assuming you've been using the combobox for a while, maybe you haven't)
Running a git bisect, seems like this was introduced here: https://github.com/josefarias/hotwire_combobox/commit/0660671f4669c3fb38eada3da34872bf04bee3a8
Taking a look now.
It seems like you already found the relevant commit, which fits with my experience. I experienced the issue with v0.2.3 and upgraded to v0.2.5 just to make sure it wasn’t already resolved. Thank you for taking a look!
@ILiuz just pushed v0.3.0. Should be fixed in that version. Thanks!
Bug description
Searching in an async combobox and then scrolling to the pagination threshold, will result in a jump to the top of the list, and not keep your current position.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
On step 3, you should keep your position in the list
Version Numbers
HotwireCombobox info
Desktop info
Additional context
I do not believe this is related to the wrap-around scrolling, but an issue with how new lazy-loaded elements are added to the list.
The file _pagination.html is responsible for producing the element that will trigger the lazy loading:
When you search the combobox, _inputtype will be set to insertText to make sure you jump to the top, for the most relevant item. Since this element is inserted with the same data-attribute every time you hit the pagination threshold in the list (unless you have done some other action, like backspace delete text), it will keep jumping you back to the top as you scroll down the list of options and lazy load more results.
I believe _inputtype should only be set to insertText on the first request after the user has entered text, and not for subsequent lazy-loaded requests, but I am not sure how to do that, or what the ramifications would be, so I filed a bug report instead of a pull request.