Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

only auto scroll if at bottom of logs #2342

wants to merge 2 commits into from

Conversation

ajp-io
Copy link
Member

@ajp-io ajp-io commented Jun 19, 2025

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

Copy link

github-actions bot commented Jun 19, 2025

This PR has been released (on staging) and is available for download with a embedded-cluster-smoke-test-staging-app license ID.

Online Installer:

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci/appver-dev-de90c6c" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Airgap Installer (may take a few minutes before the airgap bundle is built):

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci-airgap/appver-dev-de90c6c?airgap=true" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Happy debugging!

@ajp-io ajp-io force-pushed the fix-auto-scroll branch from 6233057 to ed7808d Compare June 20, 2025 13:18
@ajp-io ajp-io enabled auto-merge (squash) June 20, 2025 14:27
@ajp-io ajp-io force-pushed the fix-auto-scroll branch from ed7808d to 9394730 Compare July 2, 2025 18:51
@ajp-io ajp-io force-pushed the fix-auto-scroll branch from 9394730 to 9d07698 Compare July 11, 2025 00:57
@ajp-io ajp-io requested a review from Copilot July 11, 2025 13:24
Copy link

@Copilot Copilot AI left a 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 and handleScroll to track scroll position.
  • Updated the auto-scroll effect to consider isAtBottom before scrolling.
  • Attached ref and onScroll 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;
Copy link
Preview

Copilot AI Jul 11, 2025

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.

Suggested change
const isBottom = Math.abs(scrollHeight - clientHeight - scrollTop) < 10;
const isBottom = Math.abs(scrollHeight - clientHeight - scrollTop) < SCROLL_THRESHOLD;

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant