DEV: makes sk scroll to current selection (#9492)

This commit is contained in:
Joffrey JAFFEUX 2020-04-21 16:48:49 +02:00 committed by GitHub
parent 4f834f0008
commit 79058a6d99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 0 deletions

View File

@ -883,10 +883,31 @@ export default Component.extend(
this._safeAfterRender(() => {
this._focusFilter();
this._scrollToCurrent();
this.popper && this.popper.update();
});
},
_scrollToCurrent() {
if (this.value && this.mainCollection) {
let highlighted;
if (this.valueProperty) {
highlighted = this.mainCollection.findBy(
this.valueProperty,
this.value
);
} else {
const index = this.mainCollection.indexOf(this.value);
highlighted = this.mainCollection.objectAt(index);
}
if (highlighted) {
this._scrollToRow(highlighted);
this.set("selectKit.highlighted", highlighted);
}
}
},
_focusFilter(forceHeader = false) {
this._safeAfterRender(() => {
const input = this.getFilterInput();