fix(checkbox, radio): label is announced once on ios (#26770)

resolves #26769
This commit is contained in:
Liam DeBeasi
2023-02-09 12:36:29 -05:00
committed by GitHub
parent 52a9755ea5
commit 87bc749040
2 changed files with 27 additions and 19 deletions

View File

@ -247,6 +247,21 @@ export class Checkbox implements ComponentInterface {
})} })}
> >
<label class="checkbox-wrapper"> <label class="checkbox-wrapper">
{/*
The native control must be rendered
before the visible label text due to https://bugs.webkit.org/show_bug.cgi?id=251951
*/}
<input
type="checkbox"
aria-checked={`${checked}`}
disabled={disabled}
id={inputId}
onChange={this.toggleChecked}
onFocus={() => this.onFocus()}
onBlur={() => this.onBlur()}
ref={(focusEl) => (this.focusEl = focusEl)}
{...inheritedAttributes}
/>
<div <div
class={{ class={{
'label-text-wrapper': true, 'label-text-wrapper': true,
@ -260,17 +275,6 @@ export class Checkbox implements ComponentInterface {
{path} {path}
</svg> </svg>
</div> </div>
<input
type="checkbox"
aria-checked={`${checked}`}
disabled={disabled}
id={inputId}
onChange={this.toggleChecked}
onFocus={() => this.onFocus()}
onBlur={() => this.onBlur()}
ref={(focusEl) => (this.focusEl = focusEl)}
{...inheritedAttributes}
/>
</label> </label>
</Host> </Host>
); );

View File

@ -234,6 +234,18 @@ export class Radio implements ComponentInterface {
})} })}
> >
<label class="radio-wrapper"> <label class="radio-wrapper">
{/*
The native control must be rendered
before the visible label text due to https://bugs.webkit.org/show_bug.cgi?id=251951
*/}
<input
type="radio"
checked={checked}
disabled={disabled}
id={inputId}
ref={(nativeEl) => (this.nativeInput = nativeEl as HTMLInputElement)}
{...inheritedAttributes}
/>
<div <div
class={{ class={{
'label-text-wrapper': true, 'label-text-wrapper': true,
@ -243,14 +255,6 @@ export class Radio implements ComponentInterface {
<slot></slot> <slot></slot>
</div> </div>
<div class="native-wrapper">{this.renderRadioControl()}</div> <div class="native-wrapper">{this.renderRadioControl()}</div>
<input
type="radio"
checked={checked}
disabled={disabled}
id={inputId}
ref={(nativeEl) => (this.nativeInput = nativeEl as HTMLInputElement)}
{...inheritedAttributes}
/>
</label> </label>
</Host> </Host>
); );