From 9f046a11eaa23a9d09c4fd49d0af5798f846d3d3 Mon Sep 17 00:00:00 2001 From: Benjamin Lu Date: Fri, 17 Oct 2025 00:37:43 -0700 Subject: [PATCH] Use scrollIntoView to keep active workflow tab visible (#6077) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > "The watcher that should keep the active workflow tab visible compares the tab’s bounds against the scroll panel’s content element, whose rectangle spans the entire scroll width instead of the visible viewport. As a result, when the active tab starts off-screen, the computed offsets stay ≤ 0 and no corrective scroll occurs, so the selected tab remains hidden." fixes #6057 ------ https://chatgpt.com/codex/tasks/task_e_68efe2b5b4a08330940a20552c1db339 --- src/components/topbar/WorkflowTabs.vue | 45 ++++++++++++-------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/components/topbar/WorkflowTabs.vue b/src/components/topbar/WorkflowTabs.vue index 313d69c23..66b1f3573 100644 --- a/src/components/topbar/WorkflowTabs.vue +++ b/src/components/topbar/WorkflowTabs.vue @@ -228,33 +228,29 @@ const scroll = (direction: number) => { scrollElement.scrollBy({ left: direction * 20 }) } +const ensureActiveTabVisible = async () => { + if (!selectedWorkflow.value) return + + await nextTick() + + const scrollPanelElement = scrollPanelRef.value?.$el as + | HTMLElement + | undefined + if (!scrollPanelElement) return + + const activeTabElement = scrollPanelElement.querySelector( + '.p-togglebutton-checked' + ) as HTMLElement | null + if (!activeTabElement) return + + activeTabElement.scrollIntoView({ block: 'nearest', inline: 'nearest' }) +} + // Scroll to active offscreen tab when opened watch( () => workflowStore.activeWorkflow, - async () => { - if (!selectedWorkflow.value) return - - await nextTick() - - const activeTabElement = document.querySelector('.p-togglebutton-checked') - if (!activeTabElement || !scrollPanelRef.value) return - - const container = scrollPanelRef.value.$el.querySelector( - '.p-scrollpanel-content' - ) - if (!container) return - - const tabRect = activeTabElement.getBoundingClientRect() - const containerRect = container.getBoundingClientRect() - - const offsetLeft = tabRect.left - containerRect.left - const offsetRight = tabRect.right - containerRect.right - - if (offsetRight > 0) { - container.scrollBy({ left: offsetRight }) - } else if (offsetLeft < 0) { - container.scrollBy({ left: offsetLeft }) - } + () => { + void ensureActiveTabVisible() }, { immediate: true } ) @@ -285,6 +281,7 @@ watch(scrollContent, (value) => { void nextTick(() => { // Force a new check after arrows are updated scrollState.measure() + void ensureActiveTabVisible() }) }, { immediate: true }