From 089f315ced3425df55859f498ad519e9356df020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Wed, 10 Nov 2021 17:28:19 +0300 Subject: [PATCH] Fixed #1735 - TreeSelect should automatically scroll to show the selected option --- src/components/treeselect/TreeSelect.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/treeselect/TreeSelect.vue b/src/components/treeselect/TreeSelect.vue index 7e2143f9e..5b94a31a7 100644 --- a/src/components/treeselect/TreeSelect.vue +++ b/src/components/treeselect/TreeSelect.vue @@ -218,6 +218,7 @@ export default { this.bindOutsideClickListener(); this.bindScrollListener(); this.bindResizeListener(); + this.scrollValueInView(); this.$emit('show'); }, onOverlayLeave() { @@ -354,6 +355,14 @@ export default { this.expandedKeys[key] = true; } } + }, + scrollValueInView() { + if (this.overlay) { + let selectedItem = DomHandler.findSingle(this.overlay, 'li.p-highlight'); + if (selectedItem) { + selectedItem.scrollIntoView({ block: 'nearest', inline: 'start' }); + } + } } }, computed: {