chore(action-button): migrate api and typescript code#6346
Conversation
|
📚 Branch Preview Links🔍 First Generation 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 |
424b999 to
c61ea0f
Compare
9aef2fa to
a7f319d
Compare
3241537 to
bcb60f2
Compare
ad79936 to
bcb60f2
Compare
7edc2cb to
516540b
Compare
| | TBD | Badge slot and corner-overlay lockup (A6) | Icon+Badge and Avatar+Badge produce a distinct visual lockup. Badge text accessible name composition requires a11y review (@nikkimk) before shipping. | [A6](#additive--ships-when-ready-zero-breakage-for-consumers-already-on-2nd-gen) | | ||
| | TBD | Avatar slot and accessible name composition (A7) | Avatar accessible name and its relationship to the button's composite accessible name requires a11y review (@nikkimk) before shipping. | [A7](#additive--ships-when-ready-zero-breakage-for-consumers-already-on-2nd-gen) | | ||
| | TBD (under SWC-2039) | Cross-root ARIA mapping | Shared with `swc-button` dependency on `ElementInternals` / tooling path. | [Deferred semantics note](#deferred-semantics-note-2nd-gen) | | ||
| | Phase 4 | `aria-haspopup` / `aria-expanded` host-attribute retention | Phase 3 forwards these to the inner `<button>` via `@property` observation but does not remove the originals from the host element. ATs in browse mode may read them from the host. Proper fix (guard flag + `attributeChangedCallback` override, or `MutationObserver`) should be addressed in Phase 4 alongside a11y review. | [2nd-gen API decisions — passthrough host attributes](#properties--attributes) | |
There was a problem hiding this comment.
[nit] My understanding is that AT would skip any ARIA that isn't compatible with the role. So since the host won't have the button role, these ARIA attributes also won't be doing any harm. What might be interesting is if having or not having them would cause issues with us testing relationships such as with Menu.
There was a problem hiding this comment.
Ah yeah, it will ignore those — stripping those attributes keeps the host clean for tooling and avoids any ambiguity if the host is given a role in the future. ✨
b54227d to
2d4586e
Compare
589d0c6 to
4f6ac56
Compare
2d4586e to
8ef7445
Compare
4f6ac56 to
578f5dd
Compare
8ef7445 to
a711de4
Compare
Description
Phase 3 of the
swc-action-button1st-gen → 2nd-gen washing machine migration. This PR migrates the public API and TypeScript to the 2nd-genActionButtonclass, adds runtime deprecation warnings to 1st-gen, and cleans up the structural artifact left by Phase 2 (removing the intermediateActionButtonBaseclass from core so the package exports types only, as the migration plan specifies).2nd-gen
ActionButton.tsvaluepromoted to a getter/setter pair. When the stored value is empty,textContent.trim()is used as the effective value, matching the 1st-gen identity contract forswc-action-groupmembership.aria-haspopupandaria-expandedforwarding: private@propertyfields observe those attributes on the host and forward them into the inner<button>, enabling popup disclosure patterns without aMutationObserver.@csspropentries updated to use logical property names (--swc-action-button-min-block-size,--swc-action-button-border-radius); two incorrect entries (--swc-action-button-edge-to-text,--swc-action-button-edge-to-visual) removed.sizeoverride (added in structural fix) moves the fullxs–xlrange onto the SWC class viaVALID_SIZESstatic, a getter/setter, and a_sizebacking field. Anupdate()override counteractsSizedMixin's auto-reflect ofsize="m"for cases where no size was explicitly set.1st-gen
ActionButton.ts@deprecatedJSDoc added toemphasized,hold-affordance,selected, andtoggles.window.__swc.warn({ level: 'deprecation' })calls added inside existing code paths inupdated()for each deprecated property.Structural fix (squashed from Phase 2 branch)
ActionButton.base.tsfromcore/components/action-button/; the package now exports types only, matching the migration plan architecture table.ActionButton.ts(SWC) extendsButtonBasedirectly.Motivation and context
This is Phase 3 of the action button migration as tracked in the 2nd-gen component migration workstream. The migration plan was merged in #6327 and the structural foundation was established in the Phase 2 PR.
The
valuegetter/setter fallback and thearia-haspopup/aria-expandedforwarding are required forswc-action-groupintegration and popup disclosure patterns respectively; both are specified in the migration plan.SWC-2043
Related issue(s)
cdransf/s2-action-button-migration-structure)Screenshots (if appropriate)
N/A — TypeScript and API changes only; no visual output in this phase.
Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
valuefallback behavior<swc-action-button>with novalueattribute set and text content"Edit"element.valuein the console"Edit"(falls back totextContent.trim())valueexplicit set<swc-action-button value="edit-action">Edit</swc-action-button>element.valuein the console"edit-action"(explicit value takes precedence)aria-haspopup/aria-expandedforwarding<swc-action-button aria-haspopup="menu" aria-expanded="false">Open menu</swc-action-button><button>in DevToolsaria-haspopup="menu"andaria-expanded="false"present on the inner<button>Size attribute absent by default
<swc-action-button>Edit</swc-action-button>with nosizeattributesizeattribute on the host (the SizedMixin workaround suppresses auto-reflect ofsize="m")1st-gen deprecation warnings
window.__swc = { DEBUG: true })emphasized,selected,toggles, orhold-affordanceon a<sp-action-button>window.__swc.warnconsole message for each propertyDevice review
Accessibility testing checklist
Keyboard (required — document steps below)
swc-action-buttonStorybook stories (Playground story)disabledon the button; confirm it is no longer reachable via Tabaria-haspopup="menu"andaria-expanded="false"on the host; confirm focus and activation still work normallyScreen reader (required — document steps below)
disabledset, confirm the button is announced as dimmed/unavailablearia-haspopup="menu"andaria-expanded="false"set on the host, confirm the inner button is announced with "has popup, menu" and "collapsed"pendingset, confirmaria-disabled="true"and the pending accessible name are announced