Skip to content

fix(badge): reset text-indent to prevent inheritance (#5629)#5643

Merged
bartaz merged 2 commits intocanonical:mainfrom
Safvan-tsy:5629-badge-text-indent-fix
Dec 2, 2025
Merged

fix(badge): reset text-indent to prevent inheritance (#5629)#5643
bartaz merged 2 commits intocanonical:mainfrom
Safvan-tsy:5629-badge-text-indent-fix

Conversation

@Safvan-tsy
Copy link
Contributor

@Safvan-tsy Safvan-tsy commented Sep 17, 2025

Done

Badges inside p-checkbox inherited a negative text-indent, causing the text to disappear.
This change resets text-indent to 0 for p-badge to prevent inheritance.

Fixes #5629

QA

  • Open demo
  • [Add QA steps]
  • Review updated documentation:
    • [List any updated documentation for review]

Check if PR is ready for release

If this PR contains Vanilla SCSS or macro code changes, it should contain the following changes to make sure it's ready for the release:

  • PR should have one of the following labels to automatically categorise it in release notes:
    • Feature 🎁, Breaking Change 💣, Bug 🐛, Documentation 📝, Maintenance 🔨.
  • Vanilla version in package.json should be updated relative to the most recent release, following semver convention
    • if existing APIs (CSS classes & macro APIs) are not changed it can be a bugfix release (x.x.X)
    • if existing APIs (CSS classes & macro APIs) are changed/added/removed it should be a minor version (x.X.0)
    • see the wiki for more details
  • Any changes to component class names (new patterns, variants, removed or added features) or macros should be listed on the what's new page.

@webteam-app
Copy link

Safvan-tsy is not a collaborator of the repo

@jmuzina jmuzina self-requested a review September 18, 2025 00:45
@jmuzina jmuzina added Review: QA needed Review: Code needed Review: Percy needed This PR needs a review of Percy for visual regressions Bug 🐛 labels Sep 18, 2025
Copy link
Member

@jmuzina jmuzina left a comment

Choose a reason for hiding this comment

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

Created a version of @bartaz 's codepen from the underlying issue that we can use for QA here, since there are no badges inside forms/labels currently on the Vanilla docs sites.

https://codepen.io/jmuzina/pen/myPjjme

The badge indeed appears to render as expected when inside a checkbox/label - and there are no visual regressions.

@bartaz I want to check with you here, as in your underlying issue you reported a workaround where you selectively reset text-indent, whereas this PR resets it in all cases. I didn't find any visual regressions with this approach, do you think there are situations where this approach would cause issues?

Per the MDN docs, indentation is applied relative to the "containing block-level element's content box" - which in this case is the badge itself - so I am led to believe that this approach will work. Let me know if we're missing something.

@jmuzina jmuzina added the Question ❓ Further information is requested label Dec 1, 2025
Copy link
Member

@bartaz bartaz left a comment

Choose a reason for hiding this comment

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

Yes, I believe text-indent is fully safe to be applied this way.
My scoped approach was mostly regarding the vertical align (which was needed due to how we use badge ourselves), so it's OK for it to be omitted here I think.

@bartaz bartaz merged commit a23c346 into canonical:main Dec 2, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Badges are broken when used in filters

4 participants