Skip to content

MudScrollListener: Fix document scroll#11978

Merged
ScarletKuro merged 2 commits intoMudBlazor:devfrom
versile2:fix/scroll_for_document
Oct 21, 2025
Merged

MudScrollListener: Fix document scroll#11978
ScarletKuro merged 2 commits intoMudBlazor:devfrom
versile2:fix/scroll_for_document

Conversation

@versile2
Copy link
Contributor

While I can't speak to the intentions when this was built it seems like it was created to capture page scroll in addition to Selector scroll. This change just adds in a check when the element is "document" and grabs the scroll position. Tested with the new Service docs before porting to it's own PR. It has literal 0 effect if someone was calculating it manually via firstChild (possible) but instead returns the proper scroll positions for the first scrollable element of a document.

Checklist:

  • The PR is submitted to the correct branch (dev).
  • My code follows the style of this project.
  • I've added relevant tests or confirmed existing ones.

@versile2 versile2 requested a review from Copilot October 20, 2025 18:43
@mudbot mudbot bot changed the title mudScrollListener.js: Fix document scroll MudScrollListener: Fix document scroll Oct 20, 2025
@mudbot mudbot bot added the awaiting triage Needs maintainer review or assistance label Oct 20, 2025
Copy link
Contributor

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 fixes document-level scroll position detection in the scroll listener by adding proper handling for when the scroll target is the document itself. Instead of trying to read scroll properties directly from the document object (which doesn't work), it now uses document.scrollingElement to get accurate scroll positions.

Key Changes:

  • Added detection for document-level scroll events and proper scroll position retrieval using document.scrollingElement
  • Changed error logging from console.log to console.error for better error visibility

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes an issue with scroll position detection for full-document scrolling by checking if the event target is the document and using document.scrollingElement to retrieve accurate scroll values. The change to use console.error for logging errors is also a good improvement. I've included one suggestion to refactor the new logic to be more concise and to avoid redundant variable assignments, which aligns better with the repository's style guide. Overall, the changes are positive and address the intended problem.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@danielchalmers
Copy link
Member

While I can't speak to the intentions when this was built

The code is so old that I'm honestly not sure if anyone will be able to answer it

d7d5d37 219e728

@danielchalmers
Copy link
Member

If you think it's solid I would just merge it

@mudbot mudbot bot added bug Unexpected behavior or functionality not working as intended and removed awaiting triage Needs maintainer review or assistance labels Oct 20, 2025
@versile2
Copy link
Contributor Author

If you think it's solid I would just merge it

It's solid, simple, and shouldn't affect anything written on the public API.

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

Labels

bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants