Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/docs/src/stories/templates/combobox.a11y.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { test, expect } from '@playwright/test';

test('Combobox With Visually Hidden Label', async ({ page }) => {
await page.goto(
'http://127.0.0.1:6998/iframe.html?globals=&args=&id=templates-combobox--combobox-with-visually-hidden-label&viewMode=story'
);
await expect(page.locator('body')).toMatchAriaSnapshot(`
- region "Top right notifications"
- region "Bottom center notifications"
- combobox "Search"
- img "Open":
- img
- button "Open"
`);
});

test('Simple Suggests', async ({ page }) => {
await page.goto(
'http://127.0.0.1:6998/iframe.html?globals=&args=&id=templates-combobox--simple-suggests&viewMode=story'
Expand Down
31 changes: 31 additions & 0 deletions packages/docs/src/stories/templates/combobox.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,34 @@ export const GroupingQuery = {
</div>
`
};

/**
* ### Search Combobox with Visually Hidden Label
*
* 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.
*/
export const ComboboxWithVisuallyHiddenLabel = {
render: () => html`
<style>
.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;
}
</style>
<div class="h-[260px] w-[400px]">
<sd-combobox class="combobox-visually-hidden-label" type="search" label="Search" placement="bottom" value="">
${createFondsOptionsHtml()}
</sd-combobox>
</div>
`
};
11 changes: 11 additions & 0 deletions packages/docs/src/stories/templates/input.a11y.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { test, expect } from '@playwright/test';

test('Input With Visually Hidden Label', async ({ page }) => {
await page.goto(
'http://127.0.0.1:6998/iframe.html?globals=&args=&id=templates-input--input-with-visually-hidden-label&viewMode=story'
);
await expect(page.locator('body')).toMatchAriaSnapshot(`
- region "Top right notifications"
- region "Bottom center notifications"
- searchbox "Search"
`);
});

test('Input With Currency Stepper', async ({ page }) => {
await page.goto(
'http://127.0.0.1:6998/iframe.html?globals=&args=&id=templates-input--input-with-currency-stepper&viewMode=story'
Expand Down
29 changes: 29 additions & 0 deletions packages/docs/src/stories/templates/input.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,32 @@ export const InputWithCurrencyStepper = {
});
</script> `
};

/**
* ### 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>
</div>
`
};
Loading