Front-end theme styles can bleed into Navigation

Created on 5 March 2025, 2 months ago

Problem/Motivation

Depending the front-end themes CSS, you can run into situations where styles bleed into the Navigation components. This type of issue is not new, other admin components that need to be rendered on the front-end theme have also gone through similar issues. Some related reading on that topic:

It appears Navigation may be particularly vulnerable, b/c, although it does use an all: revert style declaration for all children, that rule is of very low specificity and is easily accidentally overridden by theme CSS.

Steps to reproduce

  • Enable the navigation module.
  • Login as admin
  • Add a style rule like the following to your front-end theme. For instance, if we add this to core/profiles/demo_umami/themes/umami/css/base.css:
button:hover,
input[type="submit"]:hover {
  background-color: red;
}
  • View any front-end page
  • Hover over the expand / collapse button in the Navigation

Expected result

The background-color of the expand/collapse button should be unchanged on hover.

Actual result

The background-color of the expand / collapse button is red. The theme CSS is bleeding through.

Proposed resolution

Review how the off-canvas dialog architects its CSS and mimic to prevent CSS bleeding through from the front-end theme. See πŸ“Œ Refactor Drupal 10 settings tray / off-canvas to use modern CSS Fixed .

Remaining tasks

Review off-canvas dialog
Review other relevant admin components that need protection on the front-end
Consider web components to isolate styles

User interface changes

TBD

πŸ› Bug report
Status

Active

Version

11.1 πŸ”₯

Component

navigation.module

Created by

πŸ‡¨πŸ‡¦Canada m4olivei Grimsby, ON

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024