-
Notifications
You must be signed in to change notification settings - Fork 402
Use scrollIntoView to keep active workflow tab visible #6077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 () => { | ||
| 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [performance] low Priority Issue: Potentially redundant DOM queries in scroll behavior
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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' }) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non blocking There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 } | ||
| ) | ||
|
|
@@ -291,6 +287,7 @@ watch(scrollContent, (value) => { | |
| void nextTick(() => { | ||
| // Force a new check after arrows are updated | ||
| scrollState.measure() | ||
| void ensureActiveTabVisible() | ||
| }) | ||
| }, | ||
| { immediate: true } | ||
|
|
||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non blocking