Docs: add scroll-margin-top for keyboard navigation #37926
Merged
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.
Description
Adds
scroll-margin-top
to the documentation styles https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-topMotivation & Context
When navigating with the keyboard, if you scroll down a documentation page and then navigate in reverse (
Shift+Tab
), keyboard focus can land behind the sticky header. This small CSS addition prevents this from happening.With a hat-tip to @joelamyman for the inspiration.
Type of changes
Video
Screen recording showing the reverse keyboard navigation before (with me jiggling the mouse at the top whenever keyboard focus is obscured by the sticky header) and after this addition.
bootstrap-scroll-margin-before-after.mp4
Note that code blocks still seem to have a funky behaviour, but this looks more like a browser bug/shortcoming.
Live previews
https://deploy-preview-37926--twbs-bootstrap.netlify.app/docs/5.3/getting-started/introduction/#community
Scroll down/jump to "Community", then navigate in reverse using
Shift+Tab