Skip to content

Improve dashboard scroll-to-bottom behavior and lifecycle - #20139

Merged
James Newton-King (JamesNK) merged 8 commits into
microsoft:mainfrom
JamesNK:dashboard-scroll-button-improvements
Sep 16, 2026
Merged

James Newton-King (JamesNK) merged 8 commits into
microsoft:mainfrom
JamesNK:dashboard-scroll-button-improvements

Conversation

@JamesNK

@JamesNK James Newton-King (JamesNK) commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Description

Improve the dashboard's scroll-to-bottom button for console logs, structured logs, and traces. The button avoids flashing during initial scroll restoration, disappears immediately when clicked, and reaches the latest content even when rows arrive during native smooth scrolling.

User-facing behavior

  • Keep native smooth scrolling. If content grows during the animation, jump to the latest bottom when scrollend fires. Respect reduced motion with immediate scrolling, and cancel the pending correction on wheel, pointer, or keyboard input.
  • Hide the button immediately on click and delay showing it by 200ms. Recheck the current scroll position before revealing it so initial auto-scrolling does not flash the control.
  • Keep the button underneath Fluent modal dialogs and their backdrops. These use the browser's top layer, so dialog-specific JavaScript hiding is unnecessary; lower the page-level button z-index from 9000 to 100.

Implementation

  • Extract scroll-button behavior from app.js into the app-scroll.js module.
  • Render a hidden <aspire-scroll-to-bottom> element inside each owning scroll container. connectedCallback registers the parent and disconnectedCallback cleans up the floating button, listeners, observer, timers, and pending animation frame. Connecting a new owner replaces the active registration; a late disconnect from the old owner cannot remove the replacement.
  • Remove document discovery scans and mutation observers. Enabling and disposing this control requires no server-side JavaScript interop. The floating button remains under <body> without modifying Blazor-owned container content.
  • Separate visibility updates from geometry updates and cache button dimensions. Container scrolling only reevaluates visibility; resize and ancestor scrolling refresh layout as needed.
  • Move data-scroll-to-bottom-label from <body> onto each web component. The owning Razor views supply the localized label, and the component uses it for the floating button's accessible name and tooltip, preserving the English fallback. Remove the unused body localizer and retain the existing focus behavior.
  • Add the new module to static-asset compression coverage.

Tests and validation

  • Add component assertions that console logs, structured logs, and traces render the hidden custom element in the correct container. All 71 affected component tests passed. Extend these assertions to verify each component's localized label; all four focused tests passed after the label change using isolated build outputs to avoid interfering with the running dashboard/debugger.
  • Refocus Playwright coverage on delayed reveal/cancellation, immediate click hiding, native scrolling with verified content growth, reduced motion, modal click blocking, replacement/disconnection/reconnection, and clipped-container visibility. Use Playwright's clock instead of a fixed sleep for reveal timing. Remove the implementation-detail layout-cache test.
  • Fix weak assertions: require growth during smooth scrolling before accepting the final bottom, test retained button listeners while their containers remain connected, and begin clipping checks with a visible control.
  • Add a browser regression test verifying that the button's accessible name and tooltip come from the custom element and that the page body no longer carries label metadata. Headless Chromium checks passed for component-local labels, labels on reconnection, and fallback behavior without body metadata.
  • The updated dashboard test project builds successfully. Browser-test compilation used BuildProjectReferences=false because a running dashboard/debugger locked its build outputs. The .NET outerloop suite was not run locally.
  • Headless Chromium checks against the production module and stylesheet passed at desktop and mobile sizes. All six revised scrolling scenarios passed, including the real Fluent modal. In-memory mutations confirmed that omitting listener cleanup or the final bottom correction is detected by the corresponding assertions. Static-asset compression tests also passed earlier in this change.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 20139

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 20139"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Browser coverage does not exercise user-input cancellation or ancestor-scroll layout updates.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Improves dashboard scroll-to-bottom behavior, lifecycle cleanup, positioning, and modal interaction.

Changes:

  • Extracts scrolling logic into a custom-element module.
  • Adds smooth-scroll correction, delayed visibility, and reduced-motion handling.
  • Expands component, browser, and compression coverage.
File summaries
File Description
tests/Aspire.Dashboard.Tests/Integration/ResponseCompressionTests.cs Covers compression of the new module.
tests/Aspire.Dashboard.Tests/Integration/Playwright/DashboardInteractionsTests.cs Revises browser interaction and lifecycle scenarios.
tests/Aspire.Dashboard.Components.Tests/Pages/TracesTests.cs Verifies the traces marker.
tests/Aspire.Dashboard.Components.Tests/Pages/StructuredLogsTests.cs Verifies the structured-logs marker.
tests/Aspire.Dashboard.Components.Tests/Controls/LogViewerTests.cs Verifies the console marker.
src/Aspire.Dashboard/wwwroot/js/app.js Removes the previous implementation.
src/Aspire.Dashboard/wwwroot/js/app-scroll.js Implements the custom element and scrolling lifecycle.
src/Aspire.Dashboard/wwwroot/css/layout.css Updates ownership documentation and stacking order.
src/Aspire.Dashboard/Components/Pages/Traces.razor Registers the traces scroll container.
src/Aspire.Dashboard/Components/Pages/StructuredLogs.razor Registers the structured-logs container.
src/Aspire.Dashboard/Components/Controls/LogViewer.razor Registers the console-log container.
src/Aspire.Dashboard/Components/App.razor Loads the new module.
Review details
  • Files reviewed: 13/13 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The user-input cancellation paths added for pending smooth-scroll correction lack browser regression coverage.

Review details

Suppressed comments (1)

src/Aspire.Dashboard/wwwroot/js/app-scroll.js:151

  • The new wheel, pointer, and keyboard handlers are not exercised by the Playwright coverage: no test sends any of these inputs while a smooth scroll has a pending scrollend correction. This leaves the user-interruption contract unprotected; add a browser test that grows the content during smooth scrolling, interrupts it through each input path, and verifies the final correction is canceled.
    const cancelForUserInput = function () {
        cancelPendingScrollToBottom(entry);
        scheduleUpdate();
    };
    container.addEventListener("wheel", cancelForUserInput, { passive: true, signal: eventController.signal });
    container.addEventListener("pointerdown", cancelForUserInput, { passive: true, signal: eventController.signal });
    container.addEventListener("keydown", cancelForUserInput, { signal: eventController.signal });
  • Files reviewed: 13/13 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The floating control ignores clipping ancestors, and user-input cancellation lacks regression coverage.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

tests/Aspire.Dashboard.Tests/Integration/Playwright/DashboardInteractionsTests.cs:112

  • This smooth-scroll test verifies that the final correction runs, but no test exercises the new wheel, pointer, or keyboard cancellation paths. Removing any of the cancelForUserInput registrations would still leave the suite green. Add coverage that grows content during the animation, dispatches each input type, and verifies the later scrollend does not jump to the new bottom.
  • Files reviewed: 13/13 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Content-only growth can leave the button inactive, and keyboard input may not cancel correction after activation.

Review details

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

src/Aspire.Dashboard/wwwroot/js/app-scroll.js:151

  • Keyboard cancellation is attached only to the container, but activating the body-level button moves focus off that container; once the click handler hides the button, subsequent key events target the document/body and never reach this listener. A keyboard attempt to interrupt the smooth scroll therefore leaves the scrollend correction armed and can still jump to the bottom. Listen for keydown at the window level (or explicitly preserve/restore container focus) so the documented cancellation works after activation.
    src/Aspire.Dashboard/wwwroot/js/app-scroll.js:162
  • The observer watches only the scroll container's own box, so streaming rows can increase scrollHeight without scheduling a visibility update. For example, if overflow is initially 100px, the user scrolls up, and later rows push it past the 240px threshold, the root remains inactive until another scroll or resize occurs. Observe the scroll-content size (including replacement content) or otherwise signal scheduleUpdate() when content grows, and cover threshold crossing while the container remains stationary.
  • Files reviewed: 13/13 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Content-height changes can leave button eligibility stale, and input cancellation lacks regression coverage.

Review details

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

src/Aspire.Dashboard/wwwroot/js/app-scroll.js:164

  • Observing only the scroll container misses changes to its scrollHeight when its fixed content box does not resize. For example, after a user scrolls to the top, filtering a 2000px grid down to 500px can leave the scrollbar present while crossing the 240px threshold; neither scroll nor this observer fires, so the body-level button remains visible with stale eligibility. Observe the scrolling content (or have the existing content-resize path notify this module) so content growth and shrinkage reevaluate visibility.

src/Aspire.Dashboard/wwwroot/js/app-scroll.js:153

  • These listeners implement the promised cancellation of the final smooth-scroll correction, but no browser test dispatches wheel, pointerdown, or keydown; the current smooth-scroll test still passes if all three listeners are removed. Add parameterized Playwright coverage that grows content during smooth scrolling, sends each input before scrollend, and verifies the final correction does not jump to the new bottom.
    container.addEventListener("wheel", cancelForUserInput, { passive: true, signal: eventController.signal });
    container.addEventListener("pointerdown", cancelForUserInput, { passive: true, signal: eventController.signal });
    container.addEventListener("keydown", cancelForUserInput, { signal: eventController.signal });
  • Files reviewed: 13/13 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation is internally consistent and includes focused component, browser, accessibility, lifecycle, and static-asset coverage.

Review details
  • Files reviewed: 13/13 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@JamesNK
James Newton-King (JamesNK) merged commit 720d66e into microsoft:main Sep 16, 2026
417 of 421 checks passed
@github-actions github-actions Bot added this to the 13.6 milestone Sep 16, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants