Skip to content
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

fix: in if-needed mode, skip bounds checking for non-scrollable scrollingElement #915

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

Chudesnov
Copy link
Contributor

@Chudesnov Chudesnov commented Dec 9, 2024

Lack of proper handling causes scroll to jump unexpectedly when targeting elements that are already in view but outside of the bounding box of the <html> element in apps that use styles like

html { height: 100%; }

to implement e.g. sticky footers

The proposed fix (checking whether document.scrollingElement is actually scrollable before checking the target element is within its bounds) is consistent with how frames other than document.scrollingElement are handled in code and also with the .scrollIntoViewIfNeeded() behavior in Chrome / .focus() in most browsers.

A workaround would be to use a more modern approach like min-height: 100vh on a specific container that needs to stretch to the height of the viewport instead, which is not always possible in legacy apps.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…lingElement
Copy link
Member

@stipsan stipsan left a comment

Choose a reason for hiding this comment

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

Thank you! 💖

@stipsan stipsan merged commit 77ae1e8 into scroll-into-view:main Jan 10, 2025
2 checks passed
Copy link
Contributor

🎉 This PR is included in version 3.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

2 participants