Skip to content

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.

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.

2 participants