Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 What kind of change does this PR introduce?
🔗 Related Issue
Self-discovered bug. No matching issue or fix PR was found during the pre-submission search.
💡 Background and solution
td-backtopregisters a scroll listener when connected but does not initialize its visibility from the current scroll position. If it is mounted after the page has already scrolled, the button remains hidden until another scroll event occurs.Call the existing visibility update function once after registering the listener. This also refreshes visibility when the same element reconnects. The visibility threshold, scroll listener cleanup and click-to-scroll behavior remain unchanged.
Reproduction
td-backtopelement without scrolling again.The screenshots use a minimal page importing the real Web Component, with no synthetic scroll event dispatched after mounting. They record actual scroll position, component state and computed button visibility.
Validation
pnpm run test: 6 files, 13 tests passed, with coverage.pnpm run typecheck,pnpm run lintandpnpm run buildpassed inpackages/site-components, including Less compilation.git diff --checkpassed.📝 Changelog
fix(site-components): Initialize Backtop visibility from the current scroll position when the element connects.
This PR does not need a changelog entry.
☑️ Checklist before requesting a merge