chore(SlotAttributePropagationController): add tests + docs#6490
chore(SlotAttributePropagationController): add tests + docs#6490cdransf wants to merge 6 commits into
Conversation
🦋 Changeset detectedLatest commit: 16b5923 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 |
📚 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 |
007aa71 to
839d90f
Compare
rubencarvalho
left a comment
There was a problem hiding this comment.
Looking really good! Nothing really blocking, but left a couple of thoughts 😄
7b36e34 to
6e01ccf
Compare
b109cca to
c25c806
Compare
ca1c45c to
86825ae
Compare
c576670 to
55cbb91
Compare
There was a problem hiding this comment.
@cdransf I will be adding a changeset in this PR as I can see this is fix we are shipping and a new public export also a bug fix. This should be a minimum patch. Also you PR description is not matching the code.
No other concerns.
55cbb91 to
bfb3aa3
Compare
Updated the description and added a changeset. ✨ |
Coverage Report for CI Build 29535143231Coverage remained the same at 96.243%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
d6bfc28 to
71edd42
Compare
… via nullable getValue
Co-authored-by: Casey Eickhoff <48574582+caseyisonit@users.noreply.github.com>
71edd42 to
16b5923
Compare
Description
Adds a
getValue/attribute-removal capability toSlotAttributePropagationController, plus unit tests and a Storybook controller docs page. The controller is already used byButtonGroupBase(default slot) andIllustratedMessageBase(namedactionsslot), but had no dedicated test coverage or documentation of its own, and could not represent an attribute that is only sometimes present on the host.Changes:
core/controllers/slot-attribute-propagation-controller/src/slot-attribute-propagation-controller.ts):getValuemay now returnstring | null. Returningnullremoves the propagated attribute from assigned elements instead of setting it to an empty string. Also fixes a bug where_previousValue(thehostUpdated()no-op guard) was set unconditionally before the slot was resolved; if the slot wasn't resolvable yet, that value was silently marked as "applied" and a laterhostUpdated()call with the same value would never re-propagate once the slot did resolve._previousValueis now only set inside_propagateToSlot(), after a successful slot resolution.core/controllers/slot-attribute-propagation-controller/test/slot-attribute-propagation-controller.test.ts): Storybook play-function tests covering first-render propagation,hostUpdated()re-propagation on value change, thepreviousValueno-op guard (including the slot-not-yet-resolved case),propagate()viaslotchange, thehostDisconnected()reset on reconnect,slotNametargeting a named slot (leaving the default slot untouched), theselectoroption filtering assigned elements, and the new nullablegetValue/ attribute-removal behavior.core/controllers/slot-attribute-propagation-controller/slot-attribute-propagation-controller.mdx+stories/): a full controller docs page (Usage, Options, Behaviors, Accessibility, hand-authored API section) plus demo hosts mirroring the two real production consumers, theselectoroption, and the nullable/optional-attribute case.SlotAttributePropagationControlleris now exported from thecorepackage's controllers barrel and package.json subpath export (@spectrum-web-components/core/controllers/slot-attribute-propagation-controller.js), matching the flat-file controller convention already used byhover-controller.js,color-controller.js, andfocus-group-navigation-controller.js.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) forlive-selection-controllertoo.slot-attribute-propagationtoslot-attribute-propagation-controllerfor consistency with sibling controller directories; all internal imports (ButtonGroup.base.ts,IllustratedMessage.base.ts) were updated accordingly.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, and could only propagate string values. A second production consumer (
ButtonGroupBase) has since adopted it, and a futureDropzoneBasemigration is expected to need to propagate an attribute that isn't always present on the host, which the originalgetValue: () => stringsignature couldn't express.Related issue(s)
Screenshots (if appropriate)
N/A — no visual/UI changes. New Storybook docs page: Controllers → Slot attribute propagation controller.
Author's checklist
patch— fix + new public export.)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; the optional-attribute demo shows the attribute being removed, not set to"", whengetValuereturnsnull)New controller tests pass
yarn workspace @spectrum-web-components/2nd-gen-swc vitest --run --project storybook -- slot-attribute-propagation-controllerslot-attribute-propagation-controller.test.tspassNo regression in existing consumers
button-groupandillustrated-messageNew public export resolves
2nd-gen/packages/core, runyarn builddist/controllers/slot-attribute-propagation-controller/index.js(and thehover-controller/focus-group-navigation-controller/live-selection-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 callssetAttribute/removeAttributewith whatever attribute name the consuming component configures.