Skip to content

Commit 923a776

Browse files
committed
fix(select): announce readonly flag in screen-reader
1 parent e4d84f6 commit 923a776

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

playwright/snapshots/si-select.spec.ts-snapshots/si-select--si-select--readonly.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
- heading "Inline" [level=4]
2-
- combobox "Inline"
2+
- textbox "Inline"
33
- heading "FormControl" [level=4]
4-
- combobox "FormControl"
4+
- textbox "FormControl"
55
- heading "Multi select" [level=4]
6-
- combobox "Multi select"
6+
- textbox "Multi select"
77
- heading "Multi-select with groups" [level=4]
8-
- combobox "Multi-select with groups"
8+
- textbox "Multi-select with groups"
99
- heading "Select with custom template" [level=4]
10-
- combobox "Select with custom template"
10+
- textbox "Select with custom template"
1111
- heading "Select with actions" [level=4]
12-
- combobox "Select with actions"
12+
- textbox "Select with actions"
1313
- text: "Control panel Current value: fair"
1414
- checkbox "Readonly" [checked]
1515
- text: Readonly

projects/element-ng/select/select-input/si-select-input.component.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ import { SelectOption } from '../si-select.types';
3737
styleUrl: './si-select-input.component.scss',
3838
changeDetection: ChangeDetectionStrategy.OnPush,
3939
host: {
40-
role: 'combobox',
40+
// In readonly mode, the select needs to be announced as a textbox.
41+
// Otherwise, screen-reader won't announce the readonly state.
4142
class: 'select focus-none dropdown-toggle d-flex align-items-center ps-4',
4243
'aria-autocomplete': 'none',
43-
'aria-haspopup': 'listbox',
44-
'[attr.aria-expanded]': 'open()',
44+
'[attr.role]': 'readonly() ? "textbox": "combobox"',
45+
'[attr.aria-haspopup]': 'readonly() ? undefined : "listbox"',
46+
'[attr.aria-expanded]': 'readonly() ? undefined : open()',
47+
'[attr.aria-controls]': 'readonly() ? undefined : controls()',
4548
'[attr.aria-readonly]': 'readonly()',
46-
'[attr.aria-controls]': 'controls()',
4749
'[attr.aria-labelledby]': 'labeledBy()',
4850
'[attr.aria-disabled]': 'selectionStrategy.disabled()',
4951
'[attr.tabindex]': 'selectionStrategy.disabled() ? "-1" : "0"',

0 commit comments

Comments
 (0)