Skip to content

chore(SlotAttributePropagationController): add tests + docs#6490

Open
cdransf wants to merge 1 commit into
mainfrom
cdransf/slot-attribute-propagation-controller-tests-docs
Open

chore(SlotAttributePropagationController): add tests + docs#6490
cdransf wants to merge 1 commit into
mainfrom
cdransf/slot-attribute-propagation-controller-tests-docs

Conversation

@cdransf

@cdransf cdransf commented Jul 9, 2026

Copy link
Copy Markdown
Member

Description

Adds unit tests and a Storybook controller docs page for SlotAttributePropagationController, a Lit ReactiveController that propagates a host attribute to elements assigned to one of its slots. The controller is already used by ButtonGroupBase (default slot) and IllustratedMessageBase (named actions slot), but had no dedicated test coverage or documentation of its own.

Changes:

  • Tests (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, the previousValue no-op guard, propagate() via slotchange, the hostDisconnected() reset on reconnect, slotName targeting a named slot (and leaving the default slot untouched), and the selector option filtering assigned elements.
  • Storybook docs (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-undemonstrated selector option.
  • Public export: SlotAttributePropagationController is now exported from the core package'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).
  • Build fix (core/vite.config.js): getEntries() now also scans controllers/*/index.ts (via scanSubdirIndexes, the same helper already used for components/), not just flat files directly in controllers/. Without this, Rollup's preserveModules output 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) for hover-controller and focusgroup-navigation-controller too. Verified by a clean rebuild and a direct import() 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 future DropzoneBase migration is expected to be a third, so test/doc coverage was needed before broader adoption.

Related issue(s)

  • fixes SWC-2311

Screenshots (if appropriate)

N/A — no visual/UI changes. New Storybook docs page: Controllers → Slot attribute propagation controller.

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed the Accessibility Practices for this feature.
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Controller docs page renders correctly

    1. Go to Storybook → Controllers → Slot attribute propagation controller
    2. Confirm the Overview, Options (Default slot / Named slot / Selector filtering), Behaviors, Accessibility, and API sections all render with no console errors
    3. Expect: each <Canvas> shows the described propagation behavior (e.g. "Named slot" shows the actions-slot button receiving size, while the default-slot paragraph does not)
  • New controller tests pass

    1. Run yarn workspace @spectrum-web-components/2nd-gen-swc vitest --run --project storybook -- slot-attribute-propagation
    2. Expect: all 7 tests in slot-attribute-propagation.test.ts pass
  • No regression in existing consumers

    1. Run the same command scoped to button-group and illustrated-message
    2. Expect: all existing size-propagation tests in both components still pass unchanged
  • New public export resolves

    1. From 2nd-gen/packages/core, run yarn build
    2. Confirm dist/controllers/slot-attribute-propagation/index.js (and the hover-controller / focusgroup-navigation-controller equivalents) exist and export their controller class

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

Accessibility testing checklist

  • Keyboard (required — document steps below)

    1. Go to Storybook → Controllers → Slot attribute propagation controller → Options → "Named slot"
    2. Tab through the rendered content: the default-slot paragraph (non-interactive) and the actions-slot button
    3. Expect: normal Tab order through the native <button> element; the propagated size attribute is a plain DOM attribute and does not affect focusability, tab order, or introduce any new tab stops
  • Screen reader (required — document steps below)

    1. Go to Storybook → Controllers → Slot attribute propagation controller → Options → "Selector filtering"
    2. With VoiceOver (or NVDA) running, navigate to both buttons
    3. Expect: both are announced as "button" with their visible text label; the propagated variant attribute carries no ARIA semantics, so no additional or altered announcements occur. The controller itself never sets role, aria-*, or any accessibility-relevant attribute — it only calls setAttribute with whatever attribute name the consuming component configures.

@cdransf cdransf self-assigned this Jul 9, 2026
@cdransf cdransf requested a review from a team as a code owner July 9, 2026 18:09
@cdransf cdransf added the Spectrum 2 Issues related to Spectrum 2 label Jul 9, 2026
@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 839d90f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

📚 Branch Preview Links

🔍 Gen1 Visual Regression Test Results

When 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: pr-6490

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

@cdransf cdransf added Status:Ready for review PR ready for review or re-review. run_vrt Triggers the Chromatic VRT run for 2nd-gen labels Jul 9, 2026
@cdransf cdransf force-pushed the cdransf/slot-attribute-propagation-controller-tests-docs branch from 18d41d9 to 007aa71 Compare July 9, 2026 21:16
@cdransf cdransf force-pushed the cdransf/slot-attribute-propagation-controller-tests-docs branch from 007aa71 to 839d90f Compare July 9, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run_vrt Triggers the Chromatic VRT run for 2nd-gen Spectrum 2 Issues related to Spectrum 2 Status:Ready for review PR ready for review or re-review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant