Skip to content

Commit

Permalink
Fixed #1535 - Dropdown v2 doesn't scroll when navigating with keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Sep 28, 2021
1 parent b735567 commit 2be35b0
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/components/dropdown/Dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,25 @@ export default {
overlayVisible: false
};
},
watch: {
value() {
this.isModelValueChanged = true;
}
},
outsideClickListener: null,
scrollHandler: null,
resizeListener: null,
searchTimeout: null,
currentSearchChar: null,
previousSearchChar: null,
searchValue: null,
isValueChanged: false,
updated() {
if (this.overlayVisible && this.isModelValueChanged) {
this.scrollValueInView();
}
this.isModelValueChanged = false;
this.onFilterUpdated();
},
beforeDestroy() {
Expand Down Expand Up @@ -465,7 +476,15 @@ export default {
if (this.overlayVisible) {
this.alignOverlay();
}
}
},
scrollValueInView() {
if (this.$refs.overlay) {
let selectedItem = DomHandler.findSingle(this.$refs.overlay, 'li.p-highlight');
if (selectedItem) {
selectedItem.scrollIntoView({ block: 'nearest', inline: 'start' });
}
}
},
},
computed: {
visibleOptions() {
Expand Down

0 comments on commit 2be35b0

Please sign in to comment.