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

Improved scrolling on Autocompleter when necessary #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

speckins
Copy link

Extends Element with .scrollIntoViewIfNecessary() which only scrolls the parent container if the element is not already entirely within view. This solves two related issues for Autocomplete dropdowns when there are scrollbars. First, if the user changes direction while scrolling through the choices, the selected LI jumps from the bottom to the top (or vice versa) of the dropdown. Second, when the autocomplete element is within a containing element with its own scrollbars, using scrollIntoView would scroll the outer scroll bars, moving the LI.selected to the top and obscuring the INPUT element. This fixes both of those problems.

I can supply a demo page if it would better illustrate.

Element.scrollIntoViewIfNecessary() only scrolls the parent container if
the element is not already entirely within view.  This solves two
related issues for autocomplete dropdowns when there are scrollbars.
First, "changing direction" while scrolling through choices is no longer
a jarring user experience.  Second, when the autocomplete element is
within a containing element with its own scrollbars, scrollIntoView
would scroll the outer scroll bars, moving the LI.selected to the top
and obscuring the INPUT element.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant