-
Notifications
You must be signed in to change notification settings - Fork 257
fix(action-button): show swc-avatar inside swc-action-button #6587
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
Changes from 8 commits
2698b49
1f016a7
d39a04b
6a79b38
8a6a2fe
63e77ef
e60ab27
5d6a8aa
6e98fd9
49b1dd7
589015a
708e037
62a1510
5635d69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@adobe/spectrum-wc': patch | ||
| --- | ||
|
|
||
| **fix(action-button):** A `<swc-avatar>` slotted into `<swc-action-button>`'s `icon` slot now automatically scales to match the button's icon size. | ||
|
|
||
| Previously, Avatar's own `size` attribute controlled its rendered size regardless of the action button's size, since Avatar's `:host([size])` sizing rule won the specificity contest with the icon slot's generic sizing rule for the avatar's _host box_ only — the visible image inside Avatar's shadow root ignored that squeeze entirely and rendered at its own `size`, causing it to overflow. Consumers previously had to manually pair an avatar `size` with the action-button `size` (e.g. `xl` action button with avatar `size="1000"`) to avoid a visual mismatch. | ||
|
|
||
| The icon slot now also sets `--swc-avatar-size` directly (the same way it already sets its own internal icon-size custom properties), which wins over Avatar's own `:host([size])` rule for a slotted avatar specifically because of how shadow-tree custom property cascading resolves rules matching via `::slotted()` against rules from the slotted element's own shadow tree. Avatar's `size` attribute becomes a no-op when slotted into an action button's icon slot; standalone avatar sizing is unaffected. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,6 +114,10 @@ slot[name="icon"]::slotted(*), | |
| slot[name="icon"]::slotted(*) { | ||
| color: inherit; | ||
| fill: currentcolor; | ||
|
|
||
| /* Lets a slotted <swc-avatar> track the icon slot's own size instead of | ||
| requiring consumers to pair its size attribute with the button's size. */ | ||
| --swc-avatar-size: var(--_swc-action-button-icon-size); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps make this more explicitly scoped to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. applied the recommendation! |
||
| } | ||
|
|
||
| /* ── Sizes ────────────────────────────────────────── */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,6 +105,7 @@ | |
| .swc-ActionButton-icon { | ||
| color: inherit; | ||
| fill: currentcolor; | ||
| --swc-avatar-size: var(--_swc-action-button-icon-size); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did this come from the generator or hand generated?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. global-component styles are auto-generated! |
||
| } | ||
|
|
||
| .swc-ActionButton--sizeXs { | ||
|
|
||
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.
This needs a VRT run.
Uh oh!
There was an error while loading. Please reload this page.
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.
Great call! I even added this to the vrt permutations :)
Uh oh!
There was an error while loading. Please reload this page.
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.
I'm glad that I did because I found another bug!!!!
Lit still leaves its child-part boundary marker, a comment node
<!--?lit$…$-->with non-empty data as a direct light-DOM child of<swc-action-button>. With no slot attribute, it lands in the default slot.Then in
slot-text-controller.ts,checkInitialContent()classifies nodes as element-or-text:A comment node has no
tagName, so it hits the last branch, andnode.textContentreturns the comment's data (?lit$…$) → trims to non-empty → hasLabel = true → iconOnly = false.