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

Cleans up scrollTo's element finding #1506

Merged
merged 1 commit into from
Mar 1, 2022

Conversation

matthew-robertson
Copy link
Contributor

This commit simplifies the search for the option to scroll to, by querying directly for the element with the right index instead of fetching all elements and then selecting from the generated array.

This feels slightly cleaner to my eyes, and has the added benefit of ensuring it's not broken by something like vertical-collection, which only renders a sliding window of options for performance reasons. The combination was causing keyboard-navigation to fail unexpectedly, since .item(19) was no longer guaranteed to be the item with data-option-index='19', nor was the array guaranteed to be long enough to have that element.

This commit replaces a somewhat convoluted query chain with
a single querySelector to fetch the specific element we want to
focus on.

This feels slightly cleaner to my eyes, but has the added benefit
of ensuring it works correctly with something like "vertical-collection",
which occluding certain elements from the list for performance reasons.
This was causing keyboard-navigation to fail unexpectedly, since `.item(19)`
was no longer guaranteed to be the item with `data-option-index='19'`, or
even to exist.
@matthew-robertson
Copy link
Contributor Author

Any thoughts on this @cibernox?

@cibernox
Copy link
Owner

cibernox commented Mar 1, 2022

If all test pass, It's way cleaner. Thanks!

@cibernox cibernox merged commit 7f8dc10 into cibernox:master Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants