Skip to content

Commit 773edeb

Browse files
fix/feat(DBCustomSelect): properly announce selected options and introduce selectedPrefix prop (#5392)
* fix(DBCustomSelect): ensure selected items are properly announced * docs: add changeset
1 parent e3936ef commit 773edeb

File tree

13 files changed

+38
-10
lines changed

13 files changed

+38
-10
lines changed

.changeset/slow-buttons-stay.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@db-ux/core-components": minor
3+
"@db-ux/ngx-core-components": minor
4+
"@db-ux/react-core-components": minor
5+
"@db-ux/wc-core-components": minor
6+
"@db-ux/v-core-components": minor
7+
---
8+
9+
fix(DBCustomSelect): properly announce selected options
10+
feat(DBCustomSelect): introduce new property `selectedPrefix`

__snapshots__/custom-select/showcase/chromium-highContrast/should-have-same-aria-snapshot/DBCustomSelect-should-have-same-aria-snapshot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@
13771377
- status
13781378
- text: Custom Selected Label
13791379
- group:
1380-
- text: Label controlled
1380+
- text: "Selected: Label controlled"
13811381
- article:
13821382
- radiogroup "id-10aasds4-Custom Selected Label":
13831383
- list:

__snapshots__/custom-select/showcase/chromium/should-have-same-aria-snapshot/DBCustomSelect-should-have-same-aria-snapshot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@
13771377
- status
13781378
- text: Custom Selected Label
13791379
- group:
1380-
- text: Label controlled
1380+
- text: "Selected: Label controlled"
13811381
- article:
13821382
- radiogroup "id-10aasds4-Custom Selected Label":
13831383
- list:

__snapshots__/custom-select/showcase/firefox/should-have-same-aria-snapshot/DBCustomSelect-should-have-same-aria-snapshot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@
13771377
- status
13781378
- text: Custom Selected Label
13791379
- group:
1380-
- text: Label controlled
1380+
- text: "Selected: Label controlled"
13811381
- article:
13821382
- radiogroup "id-10aasds4-Custom Selected Label":
13831383
- list:

__snapshots__/custom-select/showcase/mobile-chrome/should-have-same-aria-snapshot/DBCustomSelect-should-have-same-aria-snapshot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@
14421442
- status
14431443
- text: Custom Selected Label
14441444
- group:
1445-
- text: Label controlled
1445+
- text: "Selected: Label controlled"
14461446
- article:
14471447
- radiogroup "id-10aasds4-Custom Selected Label":
14481448
- list:

__snapshots__/custom-select/showcase/mobile-safari/should-have-same-aria-snapshot/DBCustomSelect-should-have-same-aria-snapshot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@
14421442
- status
14431443
- text: Custom Selected Label
14441444
- group:
1445-
- text: Label controlled
1445+
- text: "Selected: Label controlled"
14461446
- article:
14471447
- radiogroup "id-10aasds4-Custom Selected Label":
14481448
- list:

__snapshots__/custom-select/showcase/webkit/should-have-same-aria-snapshot/DBCustomSelect-should-have-same-aria-snapshot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@
13771377
- status
13781378
- text: Custom Selected Label
13791379
- group:
1380-
- text: Label controlled
1380+
- text: "Selected: Label controlled"
13811381
- article:
13821382
- radiogroup "id-10aasds4-Custom Selected Label":
13831383
- list:

packages/components/src/components/custom-select/custom-select.lite.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export default function DBCustomSelect(props: DBCustomSelectProps) {
140140
}
141141
/* For a11y reasons we need to map the correct message with the select */
142142
if (!selectRef?.validity.valid || props.validation === 'invalid') {
143-
state._descByIds = state._invalidMessageId;
143+
state.setDescById(state._invalidMessageId);
144144
state._invalidMessage =
145145
props.invalidMessage ||
146146
selectRef?.validationMessage ||
@@ -157,18 +157,18 @@ export default function DBCustomSelect(props: DBCustomSelectProps) {
157157
selectRef?.validity.valid &&
158158
props.required
159159
) {
160-
state._descByIds = state._validMessageId;
160+
state.setDescById(state._validMessageId);
161161
if (hasVoiceOver()) {
162162
state._voiceOverFallback =
163163
props.validMessage ?? DEFAULT_VALID_MESSAGE;
164164
delay(() => (state._voiceOverFallback = ''), 1000);
165165
}
166166
state._validity = props.validation ?? 'valid';
167167
} else if (stringPropVisible(props.message, props.showMessage)) {
168-
state._descByIds = state._messageId;
168+
state.setDescById(state._messageId);
169169
state._validity = props.validation ?? 'no-validation';
170170
} else {
171-
state._descByIds = state._placeholderId;
171+
state.setDescById(state._placeholderId);
172172
state._validity = props.validation ?? 'no-validation';
173173
}
174174
},
@@ -967,6 +967,11 @@ export default function DBCustomSelect(props: DBCustomSelectProps) {
967967
props.selectedType === 'tag'
968968
)}
969969
id={state._selectedLabelsId}>
970+
<Show when={props.selectedPrefix}>
971+
<span data-visually-hidden="true">
972+
{props.selectedPrefix}
973+
</span>
974+
</Show>
970975
{state._selectedLabels}
971976
</span>
972977
</Show>

packages/components/src/components/custom-select/custom-select.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@
120120
opacity: variables.$db-opacity-lg;
121121
}
122122
}
123+
124+
> span > span::after {
125+
content: ": ";
126+
}
123127
}
124128
}
125129

packages/components/src/components/custom-select/model.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ export type DBCustomSelectDefaultProps = {
191191
*/
192192
selectedLabels?: string;
193193

194+
/**
195+
* Optional: Prefix text announced by screen readers before the selection
196+
* (e.g., "Ausgewählt" or "Selected").
197+
*/
198+
selectedPrefix?: string;
199+
194200
/**
195201
* Change the selected type for values shown in multi select
196202
*/

0 commit comments

Comments
 (0)