Problem/Motivation
core/modules/navigation/css/components/admin-toolbar-control-bar.pcss.css redefines the top bar height on :root with a single leading dash in the var() reference:
:root { --admin-toolbar-top-bar-height: var(-admin-toolbar-space-64); }
-admin-toolbar-space-64 is not a custom property name, so the reference is invalid. The intended variable, --admin-toolbar-space-64, is defined in css/base/variables.pcss.css.
The same library loads top-bar.css first, which sets the correct value (calc(4 * var(--admin-toolbar-rem))). Because admin-toolbar-control-bar.css loads after it, its broken declaration can override the correct one:
- Chrome (tested: 158) ignores the broken declaration, so
--admin-toolbar-top-bar-heightkeeps its 64px value. - Firefox 161 keeps it, and
--admin-toolbar-top-bar-heightcomputes to an empty value. Anyvar(--admin-toolbar-top-bar-height)then resolves to nothing.
In Firefox 161, from 1024px up, this breaks two rules in top-bar.pcss.css that use the variable:
margin-block-starton.dialog-off-canvas-main-canvasbecomes 0, so the fixed top bar covers the top of the page content.block-sizeon.top-baris lost, so the bar takes the height of its content and padding (67px instead of 64px).
Front-end themes that offset their own fixed header with var(--admin-toolbar-top-bar-height) get an offset of 0 the same way.
The bug does not show on admin pages. The admin theme (Default Admin on main) sets --admin-toolbar-top-bar-height: 4rem on :root again in its css/layout/top-bar.css, which loads after the Navigation CSS and hides the broken value. Only front-end themes that don't redefine the variable are affected.
The typo is present on main, 11.x and 11.4.x. It is the only single-dash var() reference in core's CSS.
Steps to reproduce
- Install Drupal with the Navigation module enabled.
- Set Stark as the default theme. Any front-end theme works if it doesn't define
--admin-toolbar-top-bar-heightitself. - Create a node. Logged in as an administrator, view it on the front end (eg.
/node/1), so the top bar shows. - Open the page in Firefox 161 and in Chrome, with the window 1024px wide or more.
- Expected (Chrome): the node title shows just below the 64px top bar.
- Actual (Firefox 161): the node title is hidden under the top bar.
Proposed resolution
Remove the duplicate :root declaration from admin-toolbar-control-bar.pcss.css and rebuild the CSS. top-bar.pcss.css already defines the variable, with the same 64px value.
This duplicate was already noticed in #3446611: Not all UI elements are following rems scaling: comment #23 there lists "duplication of --admin-toolbar-top-bar-height variable in control-bar" as one of two small bugs fixed in its merge request. That issue was postponed afterwards and the change was never committed, so the duplicate, and the typo in it, is still in core. Fixing it here separately unblocks it from the postponed rem-scaling work.
The smallest alternative is to fix the reference to var(--admin-toolbar-space-64).
Remaining tasks
Decide between removing the duplicate and fixing the reference.Merge request.- Manual test with the steps above, in Firefox 161 and Chrome: after the fix.
- When RTBC, merge>/li>
User interface changes
None, apart from the fix: in Firefox 161 the top bar is 64px high again and no longer covers the page content on front-end themes.
API changes
None.
Data model changes
None.
AI disclosure
AI-Generated: Yes (Claude Code helped find the cause and draft this issue; I reproduced the bug and reviewed the text.)
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3643997 after.png | 1.7 MB | csakiistvan |
| #6 | 3643997 before.png | 1.66 MB | csakiistvan |
Issue fork drupal-3643997
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3643997-top-bar-height-var
changes, plain diff MR !18098
- 3643997-invalid-var-in
compare
Comments
Comment #4
thamasI've removed the incorrect variable declaration. Tested in Firefox 161, it fixed the problem.
Comment #5
thamasPHP 8.6 Unit failures also happen on main and are unrelated to this change.
Comment #6
csakiistvan✅ Tested and works — reproduced on a node page in Olivero as an administrator: in Firefox 161
.dialog-off-canvas-main-canvashadmargin-top: 0and the top of the site header sat under the top bar, while Chrome showed 64px. After applying MR !18098 and rebuilding caches, both browsers show 64px and the header is fully visible. The fix resolves the issue. Suggest to RTBCPrerequisites
Code review
1546e99: stylelint passes now that the CSS is recompiled. Only the allowed-to-fail PHPUnit Unit jobs fail, and they do not touch CSS.top-bar.csssets the same 64px value in the same library (navigation.libraries.yml), and no other library loadsadmin-toolbar-control-bar.css.Notes
top_bar.cssalso loads on the front end and sets--admin-toolbar-top-bar-height: 54px.mainonly in blank lines.I used AI to draft my review texts, I have manually checked its findings.
Comment #7
thamasComment #8
thamasComment #9
csakiistvan