Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions src/components/topbar/WorkflowTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -234,33 +234,29 @@ const scroll = (direction: number) => {
scrollElement.scrollBy({ left: direction * 20 })
}

// Scroll to active offscreen tab when opened
watch(
() => workflowStore.activeWorkflow,
async () => {
if (!selectedWorkflow.value) return
const ensureActiveTabVisible = async () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[architecture] low Priority

Issue: Function scope could be better optimized for component lifecycle
Context: The ensureActiveTabVisible function is defined in component scope but could benefit from being memoized or having better lifecycle management
Suggestion: Consider using useMemo or moving to a composable if this function will be reused across components, or add better cancellation for pending async operations when component unmounts

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non blocking

if (!selectedWorkflow.value) return

await nextTick()
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 scrollPanelElement = scrollPanelRef.value?.$el as
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[performance] low Priority

Issue: Potentially redundant DOM queries in scroll behavior
Context: The function queries scrollPanelElement and then queries within it, but could cache the scroll panel content element for better performance
Suggestion: Consider caching the scroll panel content element reference to avoid repeated queries, especially since this function is called frequently during scroll events

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non blocking

| HTMLElement
| undefined
if (!scrollPanelElement) return

const tabRect = activeTabElement.getBoundingClientRect()
const containerRect = container.getBoundingClientRect()
const activeTabElement = scrollPanelElement.querySelector(
'.p-togglebutton-checked'
) as HTMLElement | null
if (!activeTabElement) return

const offsetLeft = tabRect.left - containerRect.left
const offsetRight = tabRect.right - containerRect.right
activeTabElement.scrollIntoView({ block: 'nearest', inline: 'nearest' })
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[quality] medium Priority

Issue: Missing error handling for DOM operations that could fail
Context: The scrollIntoView method can throw errors if the element is not properly attached to DOM or if scrolling is restricted
Suggestion: Wrap the scrollIntoView call in a try-catch block to handle potential DOM exceptions gracefully

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non blocking

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[quality] low Priority

Issue: ScrollIntoView options may not be supported in all target browsers
Context: The block: 'nearest' and inline: 'nearest' options are relatively modern features that may not be supported in older browsers
Suggestion: Consider checking browser compatibility requirements or add a fallback for older browsers. Alternatively, document the minimum browser version requirements if not already specified

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non blocking

}

if (offsetRight > 0) {
container.scrollBy({ left: offsetRight })
} else if (offsetLeft < 0) {
container.scrollBy({ left: offsetLeft })
}
// Scroll to active offscreen tab when opened
watch(
() => workflowStore.activeWorkflow,
() => {
void ensureActiveTabVisible()
},
{ immediate: true }
)
Expand Down Expand Up @@ -291,6 +287,7 @@ watch(scrollContent, (value) => {
void nextTick(() => {
// Force a new check after arrows are updated
scrollState.measure()
void ensureActiveTabVisible()
})
},
{ immediate: true }
Expand Down