fix: Disallow header wrapping CSS #8134
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.
Although it's rare for header nav items to wrap they can and this would overlap and obscure page content. This only occurs on the desktop responsive mode. This one-liner fix prevents wrapping because our layout doesn't support wrapping anyway. This fixes #7920.
screenshot from #7920 where a user triggered this bug
In the following screenshots I modified the template to add the text "wrapping" to trigger the bug more easily.
before the fix
after the fix
The header (
<nav>
) and page content (<main>
) are in separate CSS flow layouts because the header isposition:fixed
so when the header wraps it can't push the page content down. They only appear to be adjacent due to thenavbar-offset
CSS on<body>
.This wrapping bug can be caused in several ways
This CSS fix could cause horizontal scrolling but it doesn't for me, and that seem preferable to obscuring the page content.
I considered another approach to allow wrapping and use JS to measure the height of the header (repeatedly as the user may resize their browser) and use the header height to set the
navbar-offset
but that seemed unnecessarily complicated.You may be asking yourself whether this is a lot of text for a one-liner fix, and yes — yes it is. You're welcome.