-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Badge: Support text truncation #68107
Conversation
Size Change: +101 B (+0.01%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
Flaky tests detected in 3c03080. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12581388791
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to see a simple CSS approach for truncation, especially considering we aim for a single line. Is there a reason this is a draft PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line-height: $font-line-height-small; | ||
width: fit-content; | ||
display: flex; | ||
display: inline-flex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An inline
outer display value seems more appropriate ✅
|
||
describe( 'Badge', () => { | ||
it( 'should render correctly with default props', () => { | ||
render( <Badge>Code is Poetry</Badge> ); | ||
const badge = screen.getByText( 'Code is Poetry' ); | ||
const badge = screen.getByTestId( testid ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tweaked to be more resilient against internal DOM changes.
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 If 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Does it make sense to document that the truncation is related to the max-width (imposed to the badge itself, or through its parent)?
I think we're good for now, as this is ideally something that "just works" without the consumer thinking about it. Also not sure how much we want to guarantee the specifics of this behavior as part of the backwards compatibility contract. |
* Badge: Support text truncation * Stabilize tests against internal DOM changes * Limit width to container * Add changelog Co-authored-by: mirka <[email protected]> Co-authored-by: tyxla <[email protected]> Co-authored-by: ciampo <[email protected]> Co-authored-by: jameskoster <[email protected]>
Closes #68091
What?
Add text truncation support to
Badge
.Testing Instructions
In the Storybook for Badge, use Dev Tools to add a width restriction to
.components-badge
, for examplewidth: 80px
. Alternatively, add a width restriction to a parent conatiner.Screenshots or screencast