Skip to content

Commit 97c672e

Browse files
committed
fix(action-sheet): use radio role under htmlAttributes
1 parent 8314a54 commit 97c672e

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

core/src/components/action-sheet/action-sheet-interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface ActionSheetOptions {
1919

2020
export interface ActionSheetButton<T = any> {
2121
text?: string;
22-
role?: LiteralUnion<'cancel' | 'destructive' | 'selected' | 'radio', string>;
22+
role?: LiteralUnion<'cancel' | 'destructive' | 'selected', string>;
2323
icon?: string;
2424
cssClass?: string | string[];
2525
id?: string;

core/src/components/action-sheet/action-sheet.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,10 @@ export class ActionSheet implements ComponentInterface, OverlayInterface {
313313
* Get all radio buttons (buttons with role="radio").
314314
*/
315315
private getRadioButtons(): ActionSheetButton[] {
316-
return this.getButtons().filter((b) => b.role === 'radio' && !isCancel(b.role));
316+
return this.getButtons().filter((b) => {
317+
const role = b.htmlAttributes?.role;
318+
return role === 'radio' && !isCancel(role);
319+
});
317320
}
318321

319322
/**
@@ -513,7 +516,7 @@ export class ActionSheet implements ComponentInterface, OverlayInterface {
513516
const { activeRadioId } = this;
514517

515518
return filteredButtons.map((b, index) => {
516-
const isRadio = b.role === 'radio';
519+
const isRadio = b.htmlAttributes?.role === 'radio';
517520
const buttonId = this.getButtonId(b, index);
518521
const radioButtons = this.getRadioButtons();
519522
const isActiveRadio = isRadio && buttonId === activeRadioId;

core/src/components/action-sheet/test/a11y/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ <h1>Action Sheet - A11y</h1>
108108
buttons: [
109109
{
110110
text: 'Option 1',
111-
role: 'radio',
112111
htmlAttributes: {
112+
role: 'radio',
113113
'aria-checked': 'false',
114114
},
115115
},
116116
{
117117
text: 'Option 2',
118-
role: 'radio',
119118
htmlAttributes: {
119+
role: 'radio',
120120
'aria-checked': 'true',
121121
},
122122
},

core/src/components/select/select.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,14 +559,15 @@ export class Select implements ComponentInterface {
559559
const isSelected = isOptionSelected(selectValue, value, this.compareWith);
560560

561561
return {
562-
role: 'radio',
562+
role: isOptionSelected(selectValue, value, this.compareWith) ? 'selected' : '',
563563
text: option.textContent,
564564
cssClass: optClass,
565565
handler: () => {
566566
this.setValue(value);
567567
},
568568
htmlAttributes: {
569569
'aria-checked': isSelected ? 'true' : 'false',
570+
role: 'radio',
570571
},
571572
} as ActionSheetButton;
572573
});

0 commit comments

Comments
 (0)