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
75 changes: 75 additions & 0 deletions packages/docs/src/stories/templates/combobox.a11y.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
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"
Comment on lines +11 to +13
Comment on lines +11 to +13
`);
});

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'
);
await expect(page.locator('body')).toMatchAriaSnapshot(`
- region "Top right notifications"
- region "Bottom center notifications"
- text: Funds
- combobox "Funds"
- img "Open":
- img
- button "Open"
`);
});

test('Highlight Query', async ({ page }) => {
await page.goto(
'http://127.0.0.1:6998/iframe.html?globals=&args=&id=templates-combobox--highlight-query&viewMode=story'
);
await expect(page.locator('body')).toMatchAriaSnapshot(`
- region "Top right notifications"
- region "Bottom center notifications"
- text: Funds
- combobox "Funds"
- img "Open":
- img
- button "Open"
`);
});

test('Multiple Highlight Query', async ({ page }) => {
await page.goto(
'http://127.0.0.1:6998/iframe.html?globals=&args=&id=templates-combobox--multiple-highlight-query&viewMode=story'
);
await expect(page.locator('body')).toMatchAriaSnapshot(`
- region "Top right notifications"
- region "Bottom center notifications"
- text: Funds
- combobox "Funds"
- img "Open":
- img
- button "Open"
`);
});

test('Grouping Query', async ({ page }) => {
await page.goto(
'http://127.0.0.1:6998/iframe.html?globals=&args=&id=templates-combobox--grouping-query&viewMode=story'
);
await expect(page.locator('body')).toMatchAriaSnapshot(`
- region "Top right notifications"
- region "Bottom center notifications"
- text: Group elements
- combobox "Group elements"
- img "Open":
- img
- button "Open"
`);
});
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;
}
Comment on lines +140 to +150
Comment on lines +140 to +150
</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>
`
};
25 changes: 25 additions & 0 deletions packages/docs/src/stories/templates/input.a11y.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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'
);
await expect(page.locator('body')).toMatchAriaSnapshot(`
- region "Top right notifications"
- region "Bottom center notifications"
- text: Currency stepper
- spinbutton "Currency stepper"
- text: EUR
`);
});
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;
}
Comment on lines +48 to +58
</style>
<div class="w-[250px]">
<sd-input class="input-visually-hidden-label" type="search" label="Search" placeholder="Search..."></sd-input>
Comment on lines +38 to +61
</div>
`
};
Loading