Skip to content

Boot: Adjust specificity of the image reset styles so components can size their own images - #80845

Merged
juanfra merged 2 commits into
trunkfrom
fix/boot-image-reset-specificity
Jul 30, 2026
Merged

Boot: Adjust specificity of the image reset styles so components can size their own images#80845
juanfra merged 2 commits into
trunkfrom
fix/boot-image-reset-specificity

Conversation

@juanfra

@juanfra juanfra commented Jul 29, 2026

Copy link
Copy Markdown
Member

What?

Wraps the img reset in :where() so it stops overriding components that set their own image sizes.

Why?

Found this in the font library. On "Appearance > Fonts" the cards come out at different heights creating some sort of jump when the font list is loaded, while the exact same list in the font library modal is consistent.

While trying to find why, I've found that the the reset is nested, so it compiles to .boot-layout-container .boot-layout img, one tag selector more specific than the font library's .font-library__font-card .font-library__font-variant_demo-image. height: auto wins, the previews render at their natural ratio instead of the 24px they're given (I measured images from 22 to 28px), and each row ends up as tall as its image.

The rule itself is right, an image of unknown size shouldn't blow out the layout. But the problem is that it's beating the components trying to set sizes for their images.

I can imagine this can become more evident when we start seeing more of these pages, with Dataviews (found a few places where it would happen the same).

I asked about this in the PR where the reset was added, in case the specificity was serving a specific purpose. No reply yet, so opening this in the meantime, happy to close it if it turns out to be intentional.

How?

:where() matches exactly the same images but contributes no specificity, so the reset still catches anything without a more specific rule and loses to anything with one. Removed the .boot-layout-container part since it was only there due to nesting.

Testing Instructions

  1. Open Appearance > Fonts.
  2. Go to "Install fonts" (authorize google if necessary)
  3. Navigate the different pages, and confirm the images on .font-library__font-card .font-library__font-variant_demo-image have a computed height of 24px.

Screenshots or screencast

After the fix

boot-img-reset.mp4

Before the fix (see the jump while navigating)

boot-height-auto-before.mp4

@juanfra juanfra added [Type] Enhancement A suggestion for improvement. [Package] Boot /packages/boot labels Jul 29, 2026
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: juanfra <juanfra@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: simison <simison@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Size Change: +4 B (0%)

Total Size: 7.76 MB

📦 View Changed
Filename Size Change
build/modules/boot/index.min.js 49.4 kB +4 B (+0.01%)

compressed-size-action

@juanfra
juanfra requested review from a team and youknowriad July 29, 2026 15:39
@aduth

aduth commented Jul 29, 2026

Copy link
Copy Markdown
Member

How will this be impacted or how should we think of this in relation to the SCSS modules conversion in #80359 ? (cc @simison)

@juanfra

juanfra commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

Thanks for checking this out, and pointing me to that PR @aduth! I had a look at it and the CSS touched here is migrated pretty much as is, so it looks like this would still be relevant there. .layout img is still more specific than the components, so it keeps applying to any image rendered inside the layout.

The class name changes with the migration though, so over there it'd be something like

:where(.layout) img {
	max-width: 100%;
	height: auto;
}

From what I tested the class gets hashed inside :where(), and the fix still works well.

If we all agree the fix makes sense, we could either land this and carry it over, or close this one directly and address it in #80359. cc @simison

@simison

simison commented Jul 30, 2026

Copy link
Copy Markdown
Member

Fine to merge this as a bug fix first; no need to wait! :-) (I'd also update the label from enhancement to bug)

Worth also including in WP 7.1?

@aduth aduth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense 👍 Though I do wonder if we need this rule at all, or if it's reasonable to expect that individual components are responsible for making sure that images are constrained rather than it being a page-level concern. I think the updated selector is reasonable if we want this to be page-wide, as its specificity "3-column score" would be 001 and most overrides should be at least 010 or more.

@juanfra juanfra added [Type] Bug An existing feature does not function as intended and removed [Type] Enhancement A suggestion for improvement. labels Jul 30, 2026
@juanfra

juanfra commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

Thanks! Given it's fixing a bug in the fonts page, I'd say it's worth including in 7.1.

Though I do wonder if we need this rule at all, or if it's reasonable to expect that individual components are responsible for making sure that images are constrained rather than it being a page-level concern.

I also thought about removing it completely. But then I thought the layout can also end up rendering things we don't control, plugins can register their own routes and content into these pages. Having a default there still feels useful to me and sort of a safety net for any clients using this.

@juanfra juanfra added the Backport to WP 7.1 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jul 30, 2026
@juanfra
juanfra merged commit 0d39277 into trunk Jul 30, 2026
55 checks passed
@juanfra
juanfra deleted the fix/boot-image-reset-specificity branch July 30, 2026 17:58
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Jul 30, 2026
@github-actions github-actions Bot removed the Backport to WP 7.1 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jul 30, 2026
gutenbergplugin pushed a commit that referenced this pull request Jul 30, 2026
…size their own images (#80845)

* Lower the specificity of the image reset so components can size their own images.

Co-authored-by: juanfra <juanfra@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: simison <simison@git.wordpress.org>
@github-actions github-actions Bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Jul 30, 2026
@github-actions

Copy link
Copy Markdown

I just cherry-picked this PR to the wp/7.1 branch to get it included in the next release: 6a026c9

pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Aug 5, 2026
This updates the pinned commit hash of the Gutenberg repository from `fd715a6833679d098d9fee84b642f8f1bc27341b` to `f05e40e91c54f29c449b1f33d0db89f5166812d9`.

A full list of changes included in this commit can be found on GitHub: 
WordPress/gutenberg@fd715a6...f05e40e

- Writing flow: forward delete an empty paragraph without breaking apart the next block (WordPress/gutenberg#80813)
- Upload Media: Fail the item when the /finalize request fails (WordPress/gutenberg#80725)
- Fix template `modified` and `date` return value for file templates (WordPress/gutenberg#80733)
- Boot: Adjust specificity of the image reset styles so components can size their own images (WordPress/gutenberg#80845)
- Quote: Ensure paragraph placeholder appears after deleting nested blocks (WordPress/gutenberg#77151)
- Block editor: make the Group action wrap blocks with a group transform (WordPress/gutenberg#80891)
- Copy: preserve the block when its entire text is selected (WordPress/gutenberg#80994)
- Add opt-out for block style state controls (WordPress/gutenberg#80956) (WordPress/gutenberg#81004)
- Tabs: Support Home and End keys for keyboard navigation (WordPress/gutenberg#80912)
- Rename blockStatesEnabled setting to blockStatesEditingEnabled (WordPress/gutenberg#81058)
- [WP 7.1] Background: Fix the legacy gradient UI where a gradient cannot be selected (WordPress/gutenberg#81059)
- Views: honor developer-defined view config overrides (WordPress/gutenberg#80832)
- Playlist: Add track icon (WordPress/gutenberg#81078)
- Remove the CODEOWNERS file from wp/7.1. (WordPress/gutenberg#81104)
- Notes: Email users mentioned in a note (WordPress/gutenberg#79606)
- Backport 81068 80744 80642 (WordPress/gutenberg#81135)
- Site Editor: Add E2E coverage for view config extensibility (WordPress/gutenberg#80577)
- change from WordPress/gutenberg#81068 (WordPress/gutenberg#81140)
- Link Control: Restore the preview title underline (WordPress/gutenberg#81083)
- Button: Suppress UA focus ring when focused and pressed (WordPress/gutenberg#81113)
- View config: add reference docs (WordPress/gutenberg#81149)
- Editor: Fix document tools button focus ring (WordPress/gutenberg#81115)
- Interface: Increase footer breadcrumb height to prevent focus ring clipping (WordPress/gutenberg#81156)
- Post editor: Add ThemeProvider for admin color schemes (WordPress/gutenberg#81112)
- Pass Playlist controls to track blocks (WordPress/gutenberg#81158)
- Theme: Omit color properties when neither provided nor inherited (WordPress/gutenberg#80600) (WordPress/gutenberg#81172)
- Media: Improve the HEIC upload error and keep any upload errors up until dismissed (WordPress/gutenberg#81130)
- Video: Hide settings for the GIF variation (WordPress/gutenberg#81142)
- Video: clarify the Video variation description (WordPress/gutenberg#81181)
- Button: turn on the width setting by default in theme.json (WordPress/gutenberg#81196)
- Edit Widgets: Fix header toolbar button focus ring (WordPress/gutenberg#81176)
- Build: Wrap script bundles in an IIFE to contain 'use strict' (WordPress/gutenberg#79792)
- Customizer widgets: Add ThemeProvider for admin color schemes (WordPress/gutenberg#81174)
- Fix: Tabs block: Start with empty tab labels with placeholders (WordPress/gutenberg#81197)
- PanelColorSettings: Restore the missing space below the panel header (WordPress/gutenberg#81155)
- Visual revisions: add shareable urls (WordPress/gutenberg#81205)
- Notes: fix the mention notification email composition (WordPress/gutenberg#81187)
- Fix ESLint warnings for 'navigateRegionsProps' spread (WordPress/gutenberg#81208)
- Widgets editor: Add ThemeProvider for admin color schemes (WordPress/gutenberg#81173)
- Remove the editableRoot opt-in from the paragraph block (WordPress/gutenberg#81184)
- Media Attached to: Fix issue with the popover unexpectedly flipping, tweak wording (WordPress/gutenberg#81206)
- Ensure device preview is always accurate when window is zoomed in (WordPress/gutenberg#81215)

Props wildworks.
See #65529.

git-svn-id: https://develop.svn.wordpress.org/trunk@63026 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Aug 5, 2026
This updates the pinned commit hash of the Gutenberg repository from `fd715a6833679d098d9fee84b642f8f1bc27341b` to `f05e40e91c54f29c449b1f33d0db89f5166812d9`.

A full list of changes included in this commit can be found on GitHub: 
WordPress/gutenberg@fd715a6...f05e40e

- Writing flow: forward delete an empty paragraph without breaking apart the next block (WordPress/gutenberg#80813)
- Upload Media: Fail the item when the /finalize request fails (WordPress/gutenberg#80725)
- Fix template `modified` and `date` return value for file templates (WordPress/gutenberg#80733)
- Boot: Adjust specificity of the image reset styles so components can size their own images (WordPress/gutenberg#80845)
- Quote: Ensure paragraph placeholder appears after deleting nested blocks (WordPress/gutenberg#77151)
- Block editor: make the Group action wrap blocks with a group transform (WordPress/gutenberg#80891)
- Copy: preserve the block when its entire text is selected (WordPress/gutenberg#80994)
- Add opt-out for block style state controls (WordPress/gutenberg#80956) (WordPress/gutenberg#81004)
- Tabs: Support Home and End keys for keyboard navigation (WordPress/gutenberg#80912)
- Rename blockStatesEnabled setting to blockStatesEditingEnabled (WordPress/gutenberg#81058)
- [WP 7.1] Background: Fix the legacy gradient UI where a gradient cannot be selected (WordPress/gutenberg#81059)
- Views: honor developer-defined view config overrides (WordPress/gutenberg#80832)
- Playlist: Add track icon (WordPress/gutenberg#81078)
- Remove the CODEOWNERS file from wp/7.1. (WordPress/gutenberg#81104)
- Notes: Email users mentioned in a note (WordPress/gutenberg#79606)
- Backport 81068 80744 80642 (WordPress/gutenberg#81135)
- Site Editor: Add E2E coverage for view config extensibility (WordPress/gutenberg#80577)
- change from WordPress/gutenberg#81068 (WordPress/gutenberg#81140)
- Link Control: Restore the preview title underline (WordPress/gutenberg#81083)
- Button: Suppress UA focus ring when focused and pressed (WordPress/gutenberg#81113)
- View config: add reference docs (WordPress/gutenberg#81149)
- Editor: Fix document tools button focus ring (WordPress/gutenberg#81115)
- Interface: Increase footer breadcrumb height to prevent focus ring clipping (WordPress/gutenberg#81156)
- Post editor: Add ThemeProvider for admin color schemes (WordPress/gutenberg#81112)
- Pass Playlist controls to track blocks (WordPress/gutenberg#81158)
- Theme: Omit color properties when neither provided nor inherited (WordPress/gutenberg#80600) (WordPress/gutenberg#81172)
- Media: Improve the HEIC upload error and keep any upload errors up until dismissed (WordPress/gutenberg#81130)
- Video: Hide settings for the GIF variation (WordPress/gutenberg#81142)
- Video: clarify the Video variation description (WordPress/gutenberg#81181)
- Button: turn on the width setting by default in theme.json (WordPress/gutenberg#81196)
- Edit Widgets: Fix header toolbar button focus ring (WordPress/gutenberg#81176)
- Build: Wrap script bundles in an IIFE to contain 'use strict' (WordPress/gutenberg#79792)
- Customizer widgets: Add ThemeProvider for admin color schemes (WordPress/gutenberg#81174)
- Fix: Tabs block: Start with empty tab labels with placeholders (WordPress/gutenberg#81197)
- PanelColorSettings: Restore the missing space below the panel header (WordPress/gutenberg#81155)
- Visual revisions: add shareable urls (WordPress/gutenberg#81205)
- Notes: fix the mention notification email composition (WordPress/gutenberg#81187)
- Fix ESLint warnings for 'navigateRegionsProps' spread (WordPress/gutenberg#81208)
- Widgets editor: Add ThemeProvider for admin color schemes (WordPress/gutenberg#81173)
- Remove the editableRoot opt-in from the paragraph block (WordPress/gutenberg#81184)
- Media Attached to: Fix issue with the popover unexpectedly flipping, tweak wording (WordPress/gutenberg#81206)
- Ensure device preview is always accurate when window is zoomed in (WordPress/gutenberg#81215)

Props wildworks.
See #65529.
Built from https://develop.svn.wordpress.org/trunk@63026


git-svn-id: http://core.svn.wordpress.org/trunk@62245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Package] Boot /packages/boot [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants