The dropbutton component shows its menu when JavaScript is disabled, but then quickly hides it when JS loads.
This results in a layout shift of the page, which provides a suboptimal user experience. IMHO, it makes it seem fairly janky.
This is easily viewable on the /admin/content page:

Google also highly prioritizes elimination of layout shifts, and includes a "Cumulative Layout Shift" metric within its Core Web Vitals. See
What can be done
We want to still support non-JS admin users (at least for the time being).
We fix this issue by adding a <noscript> tag to the document head, and then adding a <link> tag pointing to non-JS dropbutton styles that we migrate to a separate CSS file.
Comments
Comment #2
mherchelComment #3
mherchelWe fixed a similar issue with the mobile-friendly menus within Olivero by adding a
noscript_stylesvariable to thehtml.html.twig.This patch follows the same pattern.
That being said, it would be nice if libraries or themes/modules had an easier way to add noscript styles to a page. Maybe something like this in a
*.libraries.ymlfile could be a followup:Comment #4
mherchelComment #5
mherchelComment #6
smustgrave commentedWas able to confirm the shift as seen in the gif.
Applied the patch and no longer seeing it.
Comment #8
bnjmnmI've been wanting this addressed for a long time!
Only feedback is pretty minor.
If this goes in a
page_attachments_alterthere isn't the need to change html.html.twig, and its leveraging an existing API to add thisIt's possible this was tried and ruled out in Olivero but couldn't quickly find the relevant issue as it was implemented when Olivero was contrib. If the reasoning is already in the issue and there's a good reason to use the existing approach, link to the issue with the explanation, address item 2 (which is only needed if you keep preprocess_html) and fine to re-rtbc.
If my attachments_alter suggestion isn't implemented,and this change still happens, then this template file should be moved to a new directory. Any theme that used to have (the now removed) Classy as a subtheme had the classy templates it used copied to a /classy subdirectory to help distinguish formerly-classy from templates specific to the theme. Once we change it, it's effectively overridden and belongs to Claro, etc.
This isn't particularly apparent in Drupal 10 as the test coverage that would let you know the move was needed got removed with Classy
Comment #9
mherchelTo be honest, I'm not sure why we implemented it the way we did in Olivero. I think it was a situation where the code morphed a bunch and then it ended up there (which works well). That being said, I like this solution better because it doesn't need to modify the HTML template.
New patch and interdiff attached. Thank you :)
Comment #10
ckrinaI just tested this and it work perfect. Also, since @bnjmnm's feedback has been addressed, I'm moving this back to RTBC.
Comment #13
lauriiiWoah! I've wanted to work on this so many times since we first implemented the Claro dropbuttons. Thank you @mherchel & all! 💯
Committed c5604c9 and pushed to 11.x. Also cherry-picked to 10.1.x. Thanks! 🎉