Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
040e72a
feat: add aria-label and aria-labelledby props for improved accessibi…
sarahbrng Dec 11, 2025
017c5a7
auto update snapshots (#5625)
github-actions[bot] Dec 11, 2025
d610d4e
feat: enhance cleanSpeakInstructions for improved phrase normalizatio…
sarahbrng Dec 12, 2025
cf5fffc
feat: improve cleanSpeakInstructions for better phrase normalization …
sarahbrng Dec 12, 2025
86ce5b9
fix: update cleanSpeakInstructions to use undefined for lastVariantLa…
sarahbrng Dec 12, 2025
8012d37
auto update snapshots (#5631)
github-actions[bot] Dec 12, 2025
b46d69b
refactor: simplify cleanSpeakInstructions by removing redundant varia…
sarahbrng Dec 12, 2025
fc048d0
Merge branch '5495-changing-language-with-aria-labels-not-correctly-a…
sarahbrng Dec 12, 2025
5eea950
fix: improve phrase reordering for Windows/NVDA in cleanSpeakInstruct…
sarahbrng Dec 12, 2025
b01875c
fix: correct regex for trimming whitespace and commas in cleanSpeakIn…
sarahbrng Dec 12, 2025
c6677a9
auto update snapshots (#5632)
github-actions[bot] Dec 12, 2025
6c75784
fix: ensure ARIA labels are correctly applied to elements for improve…
sarahbrng Dec 12, 2025
b895d9c
fix: improve handling of checkbox announcements for Windows/NVDA to e…
sarahbrng Dec 15, 2025
6935037
fix: ensure consistent ordering of "check box" announcements for Wind…
sarahbrng Dec 15, 2025
8f57787
auto update snapshots (#5636)
github-actions[bot] Dec 15, 2025
d368bba
Merge branch 'main' into 5495-changing-language-with-aria-labels-not-…
michaelmkraus Dec 15, 2025
dab8842
auto update snapshots (#5637)
github-actions[bot] Dec 15, 2025
b54554b
fix: add disabled state for "True" example in switch component
sarahbrng Dec 15, 2025
152b3af
Merge branch '5495-changing-language-with-aria-labels-not-correctly-a…
sarahbrng Dec 15, 2025
2efda97
Merge branch 'main' into 5495-changing-language-with-aria-labels-not-…
michaelmkraus Dec 15, 2025
1ce973b
auto update snapshots (#5639)
github-actions[bot] Dec 15, 2025
cfe85a0
fix: update switch examples to include disabled state for "True"
sarahbrng Dec 15, 2025
925f0e0
Merge branch '5495-changing-language-with-aria-labels-not-correctly-a…
sarahbrng Dec 15, 2025
8f83f34
auto update snapshots (#5640)
github-actions[bot] Dec 15, 2025
103d139
fix: remove parentheses from switch label to avoid ID conflicts
sarahbrng Dec 15, 2025
5035400
auto update snapshots (#5642)
github-actions[bot] Dec 15, 2025
b09deeb
fix: update aria-snapshot tests for DBSwitch with correct switch names
sarahbrng Dec 15, 2025
5eebe00
fix: update switch example name for clarity
sarahbrng Dec 15, 2025
c1ab73d
Merge branch '5495-changing-language-with-aria-labels-not-correctly-a…
sarahbrng Dec 15, 2025
3986c95
auto update snapshots (#5643)
github-actions[bot] Dec 15, 2025
583d022
fix: update NVDA snapshots to match switch name with parentheses
sarahbrng Dec 16, 2025
3ae5d1c
fix: resolve React state update bug in DBSwitch causing label ID conf…
sarahbrng Dec 16, 2025
b6cad9c
auto update snapshots (#5646)
github-actions[bot] Dec 16, 2025
ad960dc
fix: resolve React state update bug in DBSwitch causing label ID conf…
sarahbrng Dec 16, 2025
6cd9a58
Merge branch '5495-changing-language-with-aria-labels-not-correctly-a…
sarahbrng Dec 16, 2025
c351db1
fix: update screen reader snapshots for DBSwitch to correct aria-labels
sarahbrng Dec 18, 2025
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
- switch "True" [checked]
- text: "True"
- status
- switch "True (Disabled)" [checked] [disabled]
- text: True (Disabled)
- status
- link "Disabled"
- switch "(Default) False"
- text: (Default) False
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
- switch "True" [checked]
- text: "True"
- status
- switch "True (Disabled)" [checked] [disabled]
- text: True (Disabled)
- status
- link "Disabled"
- switch "(Default) False"
- text: (Default) False
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
- switch "True" [checked]
- text: "True"
- status
- switch "True (Disabled)" [checked] [disabled]
- text: True (Disabled)
- status
- link "Disabled"
- switch "(Default) False"
- text: (Default) False
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
- switch "True" [checked]
- text: "True"
- status
- switch "True (Disabled)" [checked] [disabled]
- text: True (Disabled)
- status
- link "Disabled"
- switch "(Default) False"
- text: (Default) False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
- switch "True" [checked]
- text: "True"
- status
- switch "True (Disabled)" [checked] [disabled]
- text: True (Disabled)
- status
- link "Disabled"
- switch "(Default) False"
- text: (Default) False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
- switch "True" [checked]
- text: "True"
- status
- switch "True (Disabled)" [checked] [disabled]
- text: True (Disabled)
- status
- link "Disabled"
- switch "(Default) False"
- text: (Default) False
Expand Down
11 changes: 9 additions & 2 deletions packages/components/src/components/switch/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ export type DBSwitchProps = GlobalProps &
IconProps &
IconTrailingProps &
IconLeadingProps &
DBSwitchDefaultProps;
DBSwitchDefaultProps & {
/** Accessible name for the inner input. Mirrors to `aria-label`. */
ariaLabel?: string;
/** Id(s) for element(s) labelling the input. Mirrors to `aria-labelledby`. */
ariaLabelledBy?: string;
};

export type DBSwitchDefaultState = {
handleKeyDown: (event: GeneralKeyboardEvent<HTMLInputElement>) => void;
Expand All @@ -51,4 +56,6 @@ export type DBSwitchState = DBSwitchDefaultState &
ChangeEventState<HTMLInputElement> &
FocusEventState<HTMLInputElement> &
FormState &
FromValidState;
FromValidState & {
_labelId?: string;
};
15 changes: 10 additions & 5 deletions packages/components/src/components/switch/switch.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default function DBSwitch(props: DBSwitchProps) {
// jscpd:ignore-start
const state = useStore<DBSwitchState>({
_id: undefined,
_labelId: undefined as string | undefined,
_messageId: undefined as string | undefined,
_validMessageId: undefined as string | undefined,
_invalidMessageId: undefined as string | undefined,
Expand Down Expand Up @@ -156,10 +157,12 @@ export default function DBSwitch(props: DBSwitchProps) {
});

onMount(() => {
state._id = props.id ?? `switch-${uuid()}`;
state._messageId = `${state._id}${DEFAULT_MESSAGE_ID_SUFFIX}`;
state._validMessageId = `${state._id}${DEFAULT_VALID_MESSAGE_ID_SUFFIX}`;
state._invalidMessageId = `${state._id}${DEFAULT_INVALID_MESSAGE_ID_SUFFIX}`;
const id = props.id ?? `switch-${uuid()}`;
state._id = id;
state._labelId = `${id}-label`;
state._messageId = `${id}${DEFAULT_MESSAGE_ID_SUFFIX}`;
state._validMessageId = `${id}${DEFAULT_VALID_MESSAGE_ID_SUFFIX}`;
state._invalidMessageId = `${id}${DEFAULT_INVALID_MESSAGE_ID_SUFFIX}`;
state.handleValidation();
});

Expand Down Expand Up @@ -213,7 +216,7 @@ export default function DBSwitch(props: DBSwitchProps) {
data-hide-asterisk={getHideProp(props.showRequiredAsterisk)}
data-custom-validity={props.validation}
class={cls('db-switch', props.className)}>
<label htmlFor={state._id}>
<label htmlFor={state._id} id={state._labelId}>
<input
id={state._id}
type="checkbox"
Expand All @@ -226,6 +229,8 @@ export default function DBSwitch(props: DBSwitchProps) {
props.validation === 'invalid' ? 'true' : undefined
}
aria-describedby={state._descByIds}
aria-label={props.ariaLabel}
aria-labelledby={props.ariaLabelledBy ?? state._labelId}
name={props.name}
required={getBoolean(props.required, 'required')}
data-aid-icon={props.iconLeading ?? props.icon}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["(Default) False off switch","on (Default) False switch","(Default) False","True on switch","off True switch","True","True","on True switch","True"]
["(Default) False off switch","on (Default) False switch","(Default) False","True on switch","off True switch","True","True (Disabled)","on True (Disabled) switch","True (Disabled)"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["check box, not checked, (Default) False","checked","check box, checked, True","not checked","check box, not checked, True"]
["check box, not checked, (Default) False","checked","(Default) False","not checked","check box, checked, True"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["check box, not checked, (Default) False (Unchecked)","check box, checked, (Default) False (Checked)","not checked"]
["check box, not checked, (Default) False (Unchecked)","(Default) False (Unchecked)","check box, not checked, (Default) False (Unchecked)"]
37 changes: 31 additions & 6 deletions showcases/screen-reader/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ const flakyExpressions: Record<string, string> = {
'expanded. expanded': 'expanded'
};

const cleanSpeakInstructions = (phraseLog: string[]): string[] =>
phraseLog.map((phrase) => {
const cleanSpeakInstructions = (phraseLog: string[]): string[] => {
const cleaned: string[] = [];

for (const phrase of phraseLog) {
const phraseParts = phrase.split('. ');
let result = phraseParts
.filter(
Expand All @@ -67,16 +69,37 @@ const cleanSpeakInstructions = (phraseLog: string[]): string[] =>

return part;
})
.filter((part) => part.length > 0)
// Keep empty parts on Windows/NVDA to preserve snapshot placeholders
.filter((part) => (isWin() ? true : part.length > 0))
.join('. ');

// We need to replace specific phrases, as they are being reported differently on localhost and within CI/CD
for (const [key, value] of Object.entries(flakyExpressions)) {
result = result.replaceAll(key, value);
}

return result;
});
// Windows/NVDA reorders role announcements: move "check box" to the front for consistency
if (
isWin() &&
result.includes('check box') &&
!result.startsWith('check box')
) {
const [before, after] = result.split('check box');
const afterTrim = after?.replace(/^,?\s*/, '');
const beforeTrim = before?.replace(/[,\s]*$/, '');
result = `check box${afterTrim ? `, ${afterTrim}` : ''}${beforeTrim ? `, ${beforeTrim}` : ''}`;
}

// On Windows, we preserve even empty results to match snapshot baselines
if (isWin()) {
cleaned.push(result);
} else if (result) {
cleaned.push(result);
}
}

return cleaned;
};

export const generateSnapshot = async (
screenReader?: VoiceOverPlaywright | NVDAPlaywright,
Expand Down Expand Up @@ -136,7 +159,7 @@ export const runTest = async ({
if (!screenRecorder) return;

/**
* In macOS:Webkit the [automaticallySpeakWebPage](https://github.com/guidepup/guidepup/blob/main/src/macOS/VoiceOver/configureSettings.ts#L58) is active.
* In macOS:Webkit the automaticallySpeakWebPage is active.
* Therefore, we need to move back with the cursor to the start and delete the logs before starting.
* In windows:Chrome the cursor is on the middle element.
* Therefore, we need to move back and delete the logs, and then start everything.
Expand Down Expand Up @@ -188,3 +211,5 @@ const isWin = (): boolean => platform() === 'win32';

export const getTest = (): ScreenReaderTestType =>
isWin() ? nvdaTest : voiceOverTest;

// End of file
7 changes: 7 additions & 0 deletions showcases/shared/switch.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
"props": {
"checked": true
}
},
{
"name": "True (Disabled)",
"props": {
"checked": true,
"disabled": true
}
}
]
},
Expand Down