feat(actiongroup): full fidelity styles - #6484
Conversation
|
📚 Branch Preview Links🔍 Gen1 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
Coverage Report for CI Build 28956788727Warning No base build found for commit Coverage: 96.262%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats💛 - Coveralls |
91f0ed3 to
e109f49
Compare
65536e6 to
685f924
Compare
528f6f7 to
ca47cee
Compare
|
|
||
| export const Sizes: Story = { | ||
| render: () => html` | ||
| render: (args) => html` |
There was a problem hiding this comment.
The common convention in most of our other migrated components is to thread the args.
| * Note: this property does NOT set `aria-orientation` on the host. | ||
| * `aria-orientation` is only a supported ARIA attribute on roles that | ||
| * expose it (`toolbar`, `listbox`, `menu`, etc.) — `role="group"` does | ||
| * not, regardless of the roving-tabindex keyboard model implemented in | ||
| * JS. Setting it fails axe's `aria-allowed-attr` rule. Matches the same | ||
| * decision already made for `swc-button-group`. |
There was a problem hiding this comment.
This is an a11y change after it surfaced that button group also does not set aria-orientation, @nikkimk would you be able to confirm that this change makes sense?
| gap: var(--swc-action-button-gap, token("base-gap-medium")); | ||
| align-items: center; | ||
| justify-content: center; | ||
| inline-size: 100%; |
There was a problem hiding this comment.
I would love opinions about this change. It stretches the action group buttons when the action group is vertical so that all the buttons are the same width. An align-items: stretch on the .swc-ActionGroup doesn't work without it (or, doesn't have a visible effect) because it can't reach into the inner shadow DOM of the action button.
The inline-size: 100% isn't changing any stories on action button as far as I'm aware (but I will run VRTs to confirm), it only has an effect here in a vertical action group where the align-items: stretch on action group (no align-items: stretch is explicitly set, but that is the default behavior when we set .swc-ActionGroup to display: flex).
Or, TL;DR, in pictures, here's the vertical action group with inline-size: 100%:
And without inline-size: 100%:
And even more notable, without inline-size: 100% and with the compact variant set:
I would think we'd prefer the aligned version with inline-size: 100, but also want to note that React's doesn't line up nicely either:
There was a problem hiding this comment.
I don't have any objections on that. I think setting inline-size: 100% makes sense to fill the space in a flex box for each button. Playing with parent container width so far in the storybook container doesn't change the action button visually
2022776 to
8abe6f3
Compare
21f85fd to
8a31a60
Compare
There was a problem hiding this comment.
The outline in transition-property shows the black outline for a quick glance here. Removing it doesn't show this.
There was a problem hiding this comment.
I added a commit to remove it, but this prevents it from transitioning so there's no animation on it. No animation feels like maybe it's slightly better than flash of black outline 🤷♀️
The black outline is a known issue that needs more digging, since action button has it but other button components don't and it's unclear why, it's documented in SWC-2308
| }; | ||
| Quiet.storyName = 'Quiet (compact join disabled)'; | ||
|
|
||
| export const Justified: Story = { |
There was a problem hiding this comment.
When adding extra text in one of the buttons it breaks the justified layout here.
ActionButton group in RSP shows in truncation in the horizontal layout (and it also show in vertical layout but doesn't), but we don't have truncation support for swc-action-button even though swc-button has an opt-in adding truncate property.
I think maaayyybee truncate prop should be automatically for swc-action-group, because adding it for every button manually would be alot for a consumer.
There was a problem hiding this comment.
It does seem like addressing this might be dependent on adding truncated behavior to action button? So that the buttons are able to shrink as needed.
Although, FWIW, I see Gen 1's justified action group also breaks like this when the buttons aren't all able to fit on one line, although the container has to be really small before it breaks.

| } | ||
|
|
||
| /* ── Sub-elements ─────────────────────────────────── */ | ||
|
|
There was a problem hiding this comment.
:host([truncate]) .swc-ActionButton-label {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}You also probably have to add a truncate boolean property to ActionButton class as well
There was a problem hiding this comment.
Hmmm, we don't have truncate available on action button, do we? I think I'd want to do some more research on this or possibly defer an API change to action button for now.

Description
Phase 5 (styling / full fidelity) of the
swc-action-groupmigration, per SWC-2216.action-group.stories.tsto full Phase 5 scope:Anatomy,Sizes,Orientations,Static colors,Disabled,Compact(horizontal and vertical shown side by side),Quiet(demonstrates the compact-join being disabled when both are set),Justified.action-group.css: Built out from the Phase 5 stub — flex layout with size-based gap (spacing-100default,spacing-75atxs/s, translated fromspectrum-two'sactiongroup/index.css);orientation="vertical"column stacking;justifiedequal-fill viaflex: 1 1 0%;compactborder-join implemented via a CSS custom-property cascade onto--swc-action-button-border-*-radius(interior corners zeroed per child position, outer corners left at the button's natural radius); compact has no effect whenquietis also set, matching 1st-gen. Focus-ring stacking in compact mode uses:focus-withinrather than:focus-visible—delegatesFocusretargets:focus/:focus-withinonto the custom-element host in Chromium but not:focus-visible, so the original:focus-visibleselector never matched and the z-index escalation was dead, letting a focused button's ring get covered by an adjacent button's border (resolves SWC-1342).ActionGroup.ts: Wrapped the slot in an internal.swc-ActionGroupelement per the migration plan's Phase 5 checklist; added the@cssprop --swc-action-group-gapdoc tag.action-button.css/ActionButton.ts(prerequisite, per migration plan): Exposed four logical corner-radius custom properties (--swc-action-button-border-{start-start,start-end,end-start,end-end}-radius), each falling back to the existing--swc-action-button-border-radius, so action-group's compact mode can override individual corners without hardcoding a size-specific token. Also addedinline-size: 100%to.swc-ActionButton— the shadow-DOM<button>was shrink-wrapping to its own content regardless of how wide an ancestor flex layout stretched the custom-element host, soverticalandvertical+compactaction groups rendered with visibly unequal button widths even though the (invisible) host boxes were already stretched correctly.Motivation and context
Implements SWC-2216 (Phase 5: styling) of the Action Group 2nd-gen migration epic (SWC-2212), translating the
spectrum-twoS2 source (components/actiongroup/index.css) into the 2nd-gen token-based CSS structure per the approved migration plan. This is the last functional gap before Phase 6 (testing) and Phase 7 (documentation) — API and accessibility semantics were completed in SWC-2215.Related issue(s)
sp-action-groupsets z-index on focused button, hiding focus indicator (resolved)Screenshots (if appropriate)
Compactstory: horizontal and vertical variants side by side, showing joined borders with outer-corner-only rounding.Orientations,Sizes,Static colors,Justifiedstories.Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Compact join renders with correct corner radii
Compactstory in the 2nd-gen Storybook (yarn storybookfrom2nd-gen/)Compact focus ring is never clipped by a neighbor
Compactstory, Tab into the horizontal group, then press → to move through each buttonVertical and vertical + compact groups have equal-width buttons
Orientationsstory and the vertical group in theCompactstory, compare button widths visually and via DevTools (getBoundingClientRect()on eachswc-action-button's inner<button>)Quiet disables the compact join
QuietstorycompactJustified fills the available width
JustifiedstoryStandalone and horizontal action-button usage is unaffected
Playground/Overviewstories in default (horizontal) orientationinline-size: 100%change on.swc-ActionButton— standalone buttons and horizontal groups still size to content, not to 100% of some ancestorDevice review
Accessibility testing checklist
Required: Complete each applicable item and document your testing steps (replace the placeholders with your component-specific instructions).
Keyboard (required — document steps below) — What to test for: Focus order is logical; Tab reaches the component and all interactive descendants; Enter/Space activate where appropriate; arrow keys work for tabs, menus, sliders, etc.; no focus traps; Escape dismisses when applicable; focus indicator is visible.
Compactstory in 2nd-gen StorybookScreen reader (required — document steps below) — What to test for: Role and name are announced correctly; state changes (e.g. expanded, selected) are announced; labels and relationships are clear; no unnecessary or duplicate announcements.
CompactandJustifiedstories with VoiceOver (macOS) or NVDA (Windows)