-
Notifications
You must be signed in to change notification settings - Fork 5
only auto scroll if at bottom of logs #2342
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
base: main
Are you sure you want to change the base?
Conversation
This PR has been released (on staging) and is available for download with a embedded-cluster-smoke-test-staging-app license ID. Online Installer:
Airgap Installer (may take a few minutes before the airgap bundle is built):
Happy debugging! |
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.
Pull Request Overview
This PR enhances the log viewer so that it only auto-scrolls to new entries when the user is already at the bottom of the log pane, preventing unwanted repositioning when browsing historical entries.
- Added
isAtBottom
state andhandleScroll
to track scroll position. - Updated the auto-scroll effect to consider
isAtBottom
before scrolling. - Attached
ref
andonScroll
to the log container to monitor user scroll.
Comments suppressed due to low confidence (2)
web/src/components/wizard/installation/shared/LogViewer.tsx:22
- [nitpick] The function name 'handleScroll' is generic. Consider renaming it to 'handleLogContainerScroll' or 'onLogContainerScroll' to better convey its purpose.
const handleScroll = () => {
web/src/components/wizard/installation/shared/LogViewer.tsx:35
- Consider adding unit or integration tests to verify that auto-scrolling only occurs when the user is at the bottom and is disabled when scrolled up, ensuring this behavior remains covered.
}, [logs, isExpanded, isAtBottom]);
if (!logContainerRef.current) return; | ||
|
||
const { scrollTop, scrollHeight, clientHeight } = logContainerRef.current; | ||
const isBottom = Math.abs(scrollHeight - clientHeight - scrollTop) < 10; |
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.
[nitpick] The threshold value '10' is a magic number. Extract it into a named constant (e.g., SCROLL_THRESHOLD) to improve readability and make future adjustments easier.
const isBottom = Math.abs(scrollHeight - clientHeight - scrollTop) < 10; | |
const isBottom = Math.abs(scrollHeight - clientHeight - scrollTop) < SCROLL_THRESHOLD; |
Copilot uses AI. Check for mistakes.
What this PR does / why we need it:
It was impossible to scroll back through installation logs during an install, because every time a new log line was added, it would scroll you back to the bottom.
With this change, we only auto-scroll if you're already at the bottom.
Which issue(s) this PR fixes:
Does this PR require a test?
NONE
Does this PR require a release note?
Does this PR require documentation?
NONE