Problem/Motivation
Not sure how possible this actually is.
Olivero's ::isDesktopNav() method does the following:
function isDesktopNav() {
const navButtons = document.querySelector(
'[data-drupal-selector="mobile-buttons"]',
);
return navButtons
? window.getComputedStyle(navButtons).getPropertyValue('display') ===
'none'
: false;
}
the ::getComputedStyles() call causes a stylesheet recalculation on every page request on desktop, even though the DOM itself doesn't change.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| Screenshot from 2026-01-18 09-39-15.png | 154.95 KB | catch |
Issue fork drupal-3568141
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:
- 3568141-try-to-avoid
changes, plain diff MR !14388
Comments
Comment #2
catchActually here's a possible approach. In the default state where nothing has been toggled, we can skip the isDesktopNav check altogether and allow the toggling to run, because it doesn't actually change anything, it won't force a style recalculation.
Comment #4
catchComment #5
catchCalls to ::isDesktopNav show up later in the performance profile but without triggering a style recalculation. Given the element doesn't even appear to exist when this runs it seems OK to switch the check in this case. Without checking for null, managed to break several functional js tests.
Comment #8
smustgrave commentedSeems pretty straight forward. And olivero nav appears to be working the same as expected.
Comment #14
lauriiiCommitted! Thank you.