chore(SlotAttributePropagationController): add tests + docs#6490
chore(SlotAttributePropagationController): add tests + docs#6490cdransf wants to merge 1 commit into
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 |
18d41d9 to
007aa71
Compare
007aa71 to
839d90f
Compare
Description
Adds unit tests and a Storybook controller docs page for
SlotAttributePropagationController, a LitReactiveControllerthat propagates a host attribute to elements assigned to one of its slots. The controller is already used byButtonGroupBase(default slot) andIllustratedMessageBase(namedactionsslot), but had no dedicated test coverage or documentation of its own.Changes:
core/controllers/slot-attribute-propagation/test/slot-attribute-propagation.test.ts): 7 Storybook play-function tests covering first-render propagation,hostUpdated()re-propagation on value change, thepreviousValueno-op guard,propagate()viaslotchange, thehostDisconnected()reset on reconnect,slotNametargeting a named slot (and leaving the default slot untouched), and theselectoroption filtering assigned elements.core/controllers/slot-attribute-propagation/slot-attribute-propagation.mdx+stories/): a full controller docs page (Usage, Options, Behaviors, Accessibility, hand-authored API section) plus three demo hosts (default slot, named slot, selector-filtered) that mirror the two real production consumers plus the previously-undemonstratedselectoroption.SlotAttributePropagationControlleris now exported from thecorepackage's controllers barrel and package.json subpath exports (@spectrum-web-components/core/controllers/slot-attribute-propagation.js), matching every other documented controller (hover-controller,placement-controller,focusgroup-navigation-controller).core/vite.config.js):getEntries()now also scanscontrollers/*/index.ts(viascanSubdirIndexes, the same helper already used forcomponents/), not just flat files directly incontrollers/. Without this, Rollup'spreserveModulesoutput could inline a controller's re-export barrel into its parent chunk and drop the standalone file, silently breaking that controller's package.json subpath export. This was caught while adding the new export above: it turned out to already be broken (pre-existing, unnoticed) forhover-controllerandfocusgroup-navigation-controllertoo. Verified by a clean rebuild and a directimport()of all five controller subpaths.Motivation and context
SWC-2311: the controller shipped as part of the illustrated-message actions slot work with no dedicated tests or docs, as a known follow-up. A second production consumer (
ButtonGroupBase) has since adopted it, and a futureDropzoneBasemigration is expected to be a third, so test/doc coverage was needed before broader adoption.Related issue(s)
Screenshots (if appropriate)
N/A — no visual/UI changes. New Storybook docs page: Controllers → Slot attribute propagation controller.
Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Controller docs page renders correctly
<Canvas>shows the described propagation behavior (e.g. "Named slot" shows theactions-slot button receivingsize, while the default-slot paragraph does not)New controller tests pass
yarn workspace @spectrum-web-components/2nd-gen-swc vitest --run --project storybook -- slot-attribute-propagationslot-attribute-propagation.test.tspassNo regression in existing consumers
button-groupandillustrated-messageNew public export resolves
2nd-gen/packages/core, runyarn builddist/controllers/slot-attribute-propagation/index.js(and thehover-controller/focusgroup-navigation-controllerequivalents) exist and export their controller classDevice review
Accessibility testing checklist
Keyboard (required — document steps below)
actions-slot button<button>element; the propagatedsizeattribute is a plain DOM attribute and does not affect focusability, tab order, or introduce any new tab stopsScreen reader (required — document steps below)
variantattribute carries no ARIA semantics, so no additional or altered announcements occur. The controller itself never setsrole,aria-*, or any accessibility-relevant attribute — it only callssetAttributewith whatever attribute name the consuming component configures.