fix: icon inline size#6914
Conversation
aspect-ratio: 1 alone does not work reliably in all cases, so inline-size is needed alongside it.
🦋 Changeset detectedLatest commit: 73054f7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| @@ -162,6 +162,7 @@ $default-icon-font-size: var(--db-icon-font-size, #{$default-icon-size-rem}); | |||
| vertical-align: var(--db-icon-vertical-align, middle); | |||
| /* stylelint-disable-next-line db-ux/use-sizing */ | |||
| block-size: $default-icon-font-size; | |||
There was a problem hiding this comment.
| block-size: $default-icon-font-size; |
@nmerget as I don't know how to reproduce those "all cases", could we get rid of (or in other words, replace inline-size by) block-size, as we still have aspect-ratio, so does that aspect-ratio work in that direction ? to me it looks like that we could get rid of block-size than.
There was a problem hiding this comment.
The icon has to be square. Which is the normal case, but when the font is not loaded the :before just shows the content which is a text. For the text aspect-ratio is not applied correctly, inline-size does.
There is only one line extra but it makes sure that the layout won't break
There was a problem hiding this comment.
but than we could remove aspect-ratio.
| "@db-ux/core-foundations": patch | ||
| --- | ||
|
|
||
| fix: Re-add `inline-size` to icon styles because `aspect-ratio: 1` alone does not work reliably in all cases. |
There was a problem hiding this comment.
| fix: Re-add `inline-size` to icon styles because `aspect-ratio: 1` alone does not work reliably in all cases. | |
| fix: ensure that the icon fallback is displayed as a rectangle |
that was what this PR does "internally", but we should tell our users why we do it or in other words what it does fix for them.
There was a problem hiding this comment.
I didn't replace it. I add inline-size to have both
There was a problem hiding this comment.
that's fine, but still the message needs to tell the users what is changing to them, not to us or our code.
There was a problem hiding this comment.
Pull request overview
This PR addresses layout shifts that occur when an icon font fails to load by explicitly constraining the icon placeholder’s inline dimension, ensuring the icon name fallback cannot expand the layout unexpectedly.
Changes:
- Add
inline-sizeto the shared%iconstyles (alongside existingblock-size) to enforce consistent icon dimensions. - Add a Changeset to publish the fix as a patch for
@db-ux/core-foundations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/foundations/scss/icons/_icon-helpers.scss | Adds inline-size to the %icon placeholder to prevent layout shifts when icon-font fallback text appears. |
| .changeset/fix-icon-inline-size.md | Declares a patch release for @db-ux/core-foundations describing the sizing fix. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Proposed changes
If an icon-font is not loading, the icon name will destroy a layout causing layout-shifts
Checklist
Code Quality
Validation
General
feat:,fix:,chore:), as in Git Commit Conventionspackages/*folder, the correspondingAGENTS.mdhas been updated🔭🐙🐈 Test this branch here: https://design-system.deutschebahn.com/core-web/review/fix-icon-inline-size