mirror of
https://github.com/Choices-js/Choices.git
synced 2026-03-14 22:55:46 +01:00
Scroll the first selected option into the view
This commit is contained in:
parent
6f1d048e08
commit
6b30de46e6
1 changed files with 9 additions and 0 deletions
|
|
@ -521,6 +521,15 @@ class Choices {
|
|||
}
|
||||
|
||||
this.passedElement.triggerEvent(EventType.showDropdown);
|
||||
|
||||
const activeElement = this.choiceList.element.querySelector<HTMLElement>(
|
||||
getClassNamesSelector(this.config.classNames.selectedState),
|
||||
);
|
||||
|
||||
if (activeElement !== null && !isScrolledIntoView(activeElement, this.choiceList.element)) {
|
||||
// We use the native scrollIntoView function instead of choiceList.scrollToChildElement to avoid smooth scroll.
|
||||
activeElement.scrollIntoView();
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue