mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 03:00:58 +08:00
fix(select): improvements for announcing placeholder and value on screenreaders (#22556)
- Hides select text from screen readers so it isn't announced twice (Android talkback needs this) - Adds the placeholder text to be announced if there is no value - Don't add a comma if there is no value/placeholder (NVDA speech viewer) - Don't announce alert label twice
This commit is contained in:
@ -458,11 +458,12 @@ export class Select implements ComponentInterface {
|
||||
const textPart = addPlaceholderClass ? 'placeholder' : 'text';
|
||||
|
||||
// If there is a label then we need to concatenate it with the
|
||||
// current value and a comma so it separates nicely when the screen reader
|
||||
// announces it, otherwise just announce the value
|
||||
// current value (or placeholder) and a comma so it separates
|
||||
// nicely when the screen reader announces it, otherwise just
|
||||
// announce the value / placeholder
|
||||
const displayLabel = labelText !== undefined
|
||||
? `${displayValue}, ${labelText}`
|
||||
: displayValue;
|
||||
? (selectText !== '' ? `${selectText}, ${labelText}` : labelText)
|
||||
: selectText;
|
||||
|
||||
return (
|
||||
<Host
|
||||
@ -477,7 +478,7 @@ export class Select implements ComponentInterface {
|
||||
'select-disabled': disabled,
|
||||
}}
|
||||
>
|
||||
<div class={selectTextClasses} part={textPart}>
|
||||
<div aria-hidden="true" class={selectTextClasses} part={textPart}>
|
||||
{selectText}
|
||||
</div>
|
||||
<div class="select-icon" role="presentation" part="icon">
|
||||
|
Reference in New Issue
Block a user