Skip to content

Commit 27ba1f7

Browse files
committed
fix: autoscroll only when selected changes, closes #1429
1 parent 600ed22 commit 27ba1f7

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

packages/app-frontend/src/features/components/ComponentTreeNode.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { computed, toRefs, onMounted, ref, watchEffect, inject } from '@vue/composition-api'
2+
import { computed, toRefs, onMounted, ref, watchEffect, watch } from '@vue/composition-api'
33
import scrollIntoView from 'scroll-into-view-if-needed'
44
import { getComponentDisplayName, UNDEFINED } from '@utils/util'
55
import SharedData from '@utils/shared-data'
@@ -61,7 +61,7 @@ export default {
6161
6262
// Auto scroll
6363
64-
watchEffect(() => {
64+
function autoScroll () {
6565
if (selected.value && toggleEl.value) {
6666
/** @type {HTMLElement} */
6767
const el = toggleEl.value
@@ -72,7 +72,10 @@ export default {
7272
behavior: 'smooth'
7373
})
7474
}
75-
})
75+
}
76+
77+
watch(selected, () => autoScroll())
78+
watch(toggleEl, () => autoScroll())
7679
7780
return {
7881
toggleEl,

packages/app-frontend/src/features/inspector/custom/CustomInspectorNode.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { ref, computed, watch, inject, watchEffect } from '@vue/composition-api'
2+
import { ref, computed, watch, watchEffect } from '@vue/composition-api'
33
import scrollIntoView from 'scroll-into-view-if-needed'
44
import { useCurrentInspector } from '.'
55
@@ -51,7 +51,7 @@ export default {
5151
5252
const toggleEl = ref()
5353
54-
watchEffect(() => {
54+
function autoScroll () {
5555
if (selected.value && toggleEl.value) {
5656
/** @type {HTMLElement} */
5757
const el = toggleEl.value
@@ -62,7 +62,10 @@ export default {
6262
behavior: 'smooth'
6363
})
6464
}
65-
})
65+
}
66+
67+
watch(selected, () => autoScroll())
68+
watch(toggleEl, () => autoScroll())
6669
6770
return {
6871
expanded,

0 commit comments

Comments
 (0)