fix(checkbox-group): fix the checkbox-group to get it working properly with tooltips#3322
fix(checkbox-group): fix the checkbox-group to get it working properly with tooltips#3322anna-lach wants to merge 13 commits into
Conversation
…y with tooltips, unit tests and WithTooltips story
🦋 Changeset detectedLatest commit: 3bb66db The changes in this PR will be included in the next version bump. 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 💥 An error occurred when fetching the changed packages and changesets in this PR |
There was a problem hiding this comment.
Pull request overview
Fixes sl-checkbox-group behavior when non-checkbox elements (e.g., sl-tooltip) are present in its default slot, ensuring the group only operates on actual checkboxes.
Changes:
- Restrict the group’s slotted-element query to
sl-checkboxelements only. - Add a Storybook scenario demonstrating a checkbox group with tooltips in the slot.
- Add regression tests verifying the group ignores
sl-tooltipelements when computingboxesandvalue.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/components/checkbox/src/checkbox-group.ts | Filters @queryAssignedElements to only return sl-checkbox, preventing tooltip elements from being treated as checkboxes. |
| packages/components/checkbox/src/checkbox-group.stories.ts | Adds a WithTooltips story to reproduce/verify checkbox-group behavior with tooltips present. |
| packages/components/checkbox/src/checkbox-group.spec.ts | Adds regression coverage for tooltip-in-slot scenarios and registers the tooltip element for the test environment. |
🕸 Website previewYou can view a preview here (commit |
🕸 Storybook previewYou can view a preview here (commit |
a11ymiko
left a comment
There was a problem hiding this comment.
Checkbox labels are not announced by NVDA in browse mode (navigation with arrows) for Checkbox With Tooltip story. Checkboxes are announced as 'clicable chechk box required invalid entry' without name, that is provided by label.
This is announced properly in Checkbox group With Tooltips story.
Current behavior:
Screen.Recording.2026-05-14.at.17.42.26.mov
Expected behavior:
Screen.Recording.2026-05-14.at.17.43.06.mov
…ltip-breaks-sl-checkbox-group
…rying to get tooltips working properly with checkboxes
…y (issues with plain label)
…th labels properly
…ltip-breaks-sl-checkbox-group
| // If no elements could be resolved at all and the target is in the same | ||
| // scope, just remove the attribute from the host — there's nothing useful | ||
| // to set as a string attribute. For cross-scope targets, still forward the | ||
| // empty array so consumers reading the native property get a deterministic []. | ||
| if (elements.length === 0) { |
| --- | ||
|
|
||
| Fix checkbox group not working with tooltips (only `sl-checkbox` elements are tracked by `@queryAssignedElements`). | ||
| Use `ForwardAriaMixin` to forward `aria-describedby` as element references to the inner input element, enabling screen reader support. |
| resolves IDs to element references and forwards them to the focusable input element, which | ||
| properly crosses the shadow DOM boundary. |
| <sl-checkbox ${tooltip('Newsletter tooltip')} value="newsletter" | ||
| >Newsletter</sl-checkbox | ||
| > | ||
| <sl-checkbox value="promotions" aria-describedby="tooltip1">Promotions</sl-checkbox> | ||
| <sl-tooltip id="tooltip1">Promotions tooltip</sl-tooltip> | ||
| <sl-checkbox ${tooltip('Product updates tooltip')} value="updates" | ||
| >Product updates</sl-checkbox | ||
| > |

Fixes #3287