I have a multiselect dropdown created with ng-select. I'm trying to bring the scroller to top when multiple items are selected. It seems to bring the scroller to position such that last multi selected item is visible in the dropdown. Examples are shown https://ng-select.github.io/ng-select#/data-sources
I tried something ugly like this with a setTimeout. Not a fan of using setTimeout 😕
Any cleaner way of doing this? Have I missed a prop which does this for me ?
here is a reproducible demo https://stackblitz.com/edit/angular-kqzedb-p1lz6r?file=src%2Fmulti-select-default-example.component.html
<ng-select ...
(open)="onMyDropdownOpen()"
@ViewChild(NgSelectComponent) myDropdown!: NgSelectComponent;
onMyDropdownOpen(): void {
setTimeout(() => {
if (this.myDropdown?.dropdownPanel) {
this.myDropdown.dropdownPanel.scrollElementRef.nativeElement.scrollTop = 0;
}
}, 0);
}
