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-height keeps its 64px value.
  • Firefox 161 keeps it, and --admin-toolbar-top-bar-height computes to an empty value. Any var(--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-start on .dialog-off-canvas-main-canvas becomes 0, so the fixed top bar covers the top of the page content.
  • block-size on .top-bar is 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

  1. Install Drupal with the Navigation module enabled.
  2. Set Stark as the default theme. Any front-end theme works if it doesn't define --admin-toolbar-top-bar-height itself.
  3. Create a node. Logged in as an administrator, view it on the front end (eg. /node/1), so the top bar shows.
  4. 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.)

Issue fork drupal-3643997

Command icon 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:

Comments

thamas created an issue. See original summary.

thamas changed the visibility of the branch 3643997-invalid-var-in to hidden.

thamas’s picture

Status: Active » Needs review

I've removed the incorrect variable declaration. Tested in Firefox 161, it fixed the problem.

thamas’s picture

PHP 8.6 Unit failures also happen on main and are unrelated to this change.

csakiistvan’s picture

StatusFileSize
new1.66 MB
new1.7 MB

✅ Tested and works — reproduced on a node page in Olivero as an administrator: in Firefox 161 .dialog-off-canvas-main-canvas had margin-top: 0 and 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 RTBC

Prerequisites
  • Navigation enabled, Olivero as the front-end theme, Claro as the admin theme.
Code review
  • MR !18098 at 1546e99: stylelint passes now that the CSS is recompiled. Only the allowed-to-fail PHPUnit Unit jobs fail, and they do not touch CSS.
  • Removing the declaration is safe: top-bar.css sets the same 64px value in the same library (navigation.libraries.yml), and no other library loads admin-toolbar-control-bar.css.
Notes
  • Gin as the admin theme hides the bug: its top_bar.css also loads on the front end and sets --admin-toolbar-top-bar-height: 54px.
  • In Olivero the node title stays visible. The bug shows as the top 64px of the site header hidden under the top bar.
  • Tested on 11.4.x; the affected file there differs from main only in blank lines.

I used AI to draft my review texts, I have manually checked its findings.

thamas’s picture

Assigned: thamas » Unassigned
thamas’s picture

Issue summary: View changes
csakiistvan’s picture

Status: Needs review » Reviewed & tested by the community