Repository navigation
Conversation
Wrap the label in an inline block, which an underline from a surrounding link does not propagate into. The badge itself cannot block it when it is a flex or grid item, because those are always blockified. Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URyKcjmHwMrNzohTbkh
Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URyKcjmHwMrNzohTbkh
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +565 B (+0.01%) Total Size: 8.68 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Navigates the list via UP/DOWN arrow keys from action buttons in
|
Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URyKcjmHwMrNzohTbkh
Co-authored-by: t-hamano <54422211+t-hamano@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011g9URyKcjmHwMrNzohTbkh
mirka
left a comment
There was a problem hiding this comment.
It's a bit questionable whether the new wrapping behavior would still make the badge read as a badge. It's now ambiguous whether it could be a small input or button. But unfortunately the fix seems to require it, and I agree it's worth fixing.
However, the truncation isn't required for the fix, right? The decision not to add truncation by default was a conscious decision, so I'd prefer not adding it here if it's not necessary.
| variant="body-sm" | ||
| > | ||
| { children } | ||
| <span className={ styles.label }>{ children }</span> |
There was a problem hiding this comment.
DataViews' grid and pickerGrid layouts hide empty badge fields with :empty. The label span makes those badges non-empty even when the field renders null or '', so an empty pill becomes visible. Can we keep the empty-field hiding in both layouts? Maybe like :has(> :only-child:empty).
| .label { | ||
| display: inline-block; | ||
| max-width: 100%; | ||
| overflow: hidden; |
There was a problem hiding this comment.
(May not be needed if we drop the truncation)
overflow: hidden clips glyphs that extend past the 16px line box. Thai tone marks lose about a pixel at the top. Extending the clip area keeps the layout the same and avoids that:
| overflow: hidden; | |
| overflow: hidden; | |
| padding-block: var(--wpds-dimension-padding-xs); | |
| margin-block: calc(-1 * var(--wpds-dimension-padding-xs)); |
|
Agree that's a shame but I think it's an acceptable trade-off; wrapping badges should really be an edge case. |
I found this while exploring the approach suggested in #86937 (comment).
What?
Stops the underline of a surrounding link from reaching the
ui/Badgelabel, including when the badge is a flex or grid item.Why?
In Site Editor v2, the page list renders titles as links, so the "Privacy Policy Page" badge next to the title is underlined too.
ui/Badgehas no inner element to block the underline, unlikecomponents/Badge, which fixed the same issue in #72097. This latent issue surfaced when #82499 migrated the page title badge toui/Badge.Setting
display: inline-block; text-decoration: noneon the badge itself is not enough: a flex or grid item is always blockified, andtext-decoration: nonecannot remove an underline inherited from an ancestor.How?
spanrendered as an inline block, which an underline does not propagate into.max-width: 100%, so a long label wraps inside the badge.overflow: hiddenandtext-overflow: ellipsisto the label, so a badge withwhite-space: nowrapstill truncates with an ellipsis.The existing stories render pixel-identical before and after. A single word longer than the badge now ends with an ellipsis instead of overflowing the border.
Testing Instructions
ui/Badgestories in Storybook and confirm they look unchanged.Screenshots or screencast
Use of AI Tools
This PR was authored with Claude Code (Claude Opus 5.5), including the investigation, the fix and the screenshots, and reviewed by the author.