Refactor #1451 - For keyboard support on Dropdown

pull/1994/head
mertsincan 2021-08-17 11:24:42 +03:00
parent 3f003a9817
commit 4cfa62f29e
1 changed files with 14 additions and 1 deletions

View File

@ -138,6 +138,11 @@ export default {
overlayVisible: false overlayVisible: false
}; };
}, },
watch: {
modelValue() {
this.isModelValueChanged = true;
}
},
outsideClickListener: null, outsideClickListener: null,
scrollHandler: null, scrollHandler: null,
resizeListener: null, resizeListener: null,
@ -148,6 +153,14 @@ export default {
overlay: null, overlay: null,
itemsWrapper: null, itemsWrapper: null,
virtualScroller: null, virtualScroller: null,
isModelValueChanged: false,
updated() {
if (this.overlayVisible && this.isModelValueChanged) {
this.scrollValueInView();
}
this.isModelValueChanged = false;
},
beforeUnmount() { beforeUnmount() {
this.unbindOutsideClickListener(); this.unbindOutsideClickListener();
this.unbindResizeListener(); this.unbindResizeListener();
@ -611,7 +624,7 @@ export default {
if (this.overlay) { if (this.overlay) {
let selectedItem = DomHandler.findSingle(this.overlay, 'li.p-highlight'); let selectedItem = DomHandler.findSingle(this.overlay, 'li.p-highlight');
if (selectedItem) { if (selectedItem) {
this.itemsWrapper.scrollTop = selectedItem.offsetTop; selectedItem.scrollIntoView({ block: 'nearest', inline: 'start' });
} }
} }
}, },