[no ci] feat(1958): add template to sd-input without label but still accessible#2964
Conversation
…le, implemented by agent
|
|
🚀 Storybook has been deployed for branch |
…at/ui-1958-add-template-to-sd-input-without-label-but-still-accessible # Conflicts: # packages/docs/src/stories/templates/combobox.a11y.ts # packages/docs/src/stories/templates/input.a11y.ts
…le, add removed a11y test files again
There was a problem hiding this comment.
Pull request overview
Adds accessibility-focused template examples for search input and combobox variants that keep labels available to assistive technology while visually hiding them, plus Playwright ARIA snapshot coverage.
Changes:
- Adds visually hidden label examples for
sd-inputandsd-combobox. - Adds new template accessibility test files for input and combobox stories.
- Extends coverage to existing input/combobox template stories in those files.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
packages/docs/src/stories/templates/input.stories.ts |
Adds the visually hidden search input label template. |
packages/docs/src/stories/templates/input.a11y.ts |
Adds ARIA snapshot tests for input templates. |
packages/docs/src/stories/templates/combobox.stories.ts |
Adds the visually hidden search combobox label template. |
packages/docs/src/stories/templates/combobox.a11y.ts |
Adds ARIA snapshot tests for combobox templates. |
| - img "Open": | ||
| - img | ||
| - button "Open" |
| await expect(page.locator('body')).toMatchAriaSnapshot(` | ||
| - region "Top right notifications" | ||
| - region "Bottom center notifications" | ||
| - searchbox "Search" |
| * Use this pattern when a search input should not show a visible label but still needs to be accessible to screen readers. | ||
| * The label is visually hidden via `::part(form-control-label)` while remaining available in the accessibility tree. | ||
| * | ||
| * __Warning:__ Visually hidden labels are only permitted for search inputs (WCAG Success Criterion 1.3.1). Do not use this pattern for other input types. |
| * Use this pattern when a search combobox should not show a visible label but still needs to be accessible to screen readers. | ||
| * The label is visually hidden via `::part(form-control-label)` while remaining available in the accessibility tree. | ||
| * | ||
| * __Warning:__ Visually hidden labels are only permitted for search inputs (WCAG Success Criterion 1.3.1). Do not use this pattern for other input types. |
| .input-visually-hidden-label::part(form-control-label) { | ||
| position: absolute; | ||
| width: 1px; | ||
| height: 1px; | ||
| padding: 0; | ||
| margin: -1px; | ||
| overflow: hidden; | ||
| clip: rect(0, 0, 0, 0); | ||
| white-space: nowrap; | ||
| border-width: 0; | ||
| } |
| .combobox-visually-hidden-label::part(form-control-label) { | ||
| position: absolute; | ||
| width: 1px; | ||
| height: 1px; | ||
| padding: 0; | ||
| margin: -1px; | ||
| overflow: hidden; | ||
| clip: rect(0, 0, 0, 0); | ||
| white-space: nowrap; | ||
| border-width: 0; | ||
| } |
|
@copilot: use the write-template-stories skill to review the new template stories in this PR. |
| await expect(page.locator('body')).toMatchAriaSnapshot(` | ||
| - region "Top right notifications" | ||
| - region "Bottom center notifications" | ||
| - searchbox "Search" |
| - img "Open": | ||
| - img | ||
| - button "Open" |
| * Use this pattern when a search input should not show a visible label but still needs to be accessible to screen readers. | ||
| * The label is visually hidden via `::part(form-control-label)` while remaining available in the accessibility tree. | ||
| * | ||
| * __Warning:__ Visually hidden labels are only permitted for search inputs (WCAG Success Criterion 1.3.1). Do not use this pattern for other input types. |
| * Use this pattern when a search combobox should not show a visible label but still needs to be accessible to screen readers. | ||
| * The label is visually hidden via `::part(form-control-label)` while remaining available in the accessibility tree. | ||
| * | ||
| * __Warning:__ Visually hidden labels are only permitted for search inputs (WCAG Success Criterion 1.3.1). Do not use this pattern for other input types. |
| * ### Search Input with Visually Hidden Label | ||
| * | ||
| * Use this pattern when a search input should not show a visible label but still needs to be accessible to screen readers. | ||
| * The label is visually hidden via `::part(form-control-label)` while remaining available in the accessibility tree. | ||
| * | ||
| * __Warning:__ Visually hidden labels are only permitted for search inputs (WCAG Success Criterion 1.3.1). Do not use this pattern for other input types. | ||
| */ | ||
| export const InputWithVisuallyHiddenLabel = { | ||
| render: () => html` | ||
| <style> | ||
| .input-visually-hidden-label::part(form-control-label) { | ||
| position: absolute; | ||
| width: 1px; | ||
| height: 1px; | ||
| padding: 0; | ||
| margin: -1px; | ||
| overflow: hidden; | ||
| clip: rect(0, 0, 0, 0); | ||
| white-space: nowrap; | ||
| border-width: 0; | ||
| } | ||
| </style> | ||
| <div class="w-[250px]"> | ||
| <sd-input class="input-visually-hidden-label" type="search" label="Search" placeholder="Search..."></sd-input> |
| .combobox-visually-hidden-label::part(form-control-label) { | ||
| position: absolute; | ||
| width: 1px; | ||
| height: 1px; | ||
| padding: 0; | ||
| margin: -1px; | ||
| overflow: hidden; | ||
| clip: rect(0, 0, 0, 0); | ||
| white-space: nowrap; | ||
| border-width: 0; | ||
| } |
NOTE: implemented by agent "Github Issue implementer"
Description:
This pull request adds new accessibility-focused examples and corresponding automated tests for visually hidden labels in both combobox and search input components. These changes demonstrate how to implement visually hidden labels that remain accessible to screen readers, following WCAG guidelines.
Accessibility examples:
ComboboxWithVisuallyHiddenLabel, incombobox.stories.tsto showcase a search combobox with a visually hidden label, including styling and usage notes compliant with WCAG.InputWithVisuallyHiddenLabel, ininput.stories.tsto demonstrate a search input with a visually hidden label, complete with appropriate styling and accessibility warnings.Automated accessibility tests:
Combobox With Visually Hidden Label, incombobox.a11y.tsto verify the accessibility tree for the new combobox example.Input With Visually Hidden Label, ininput.a11y.tsto check the accessibility tree for the new input example.Definition of Reviewable: