Skip to content

Commit d5197be

Browse files
committed
fix(select): add aria-selected to button option
1 parent 58d5638 commit d5197be

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/src/components/select/select.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ export class Select implements ComponentInterface {
548548
}
549549

550550
private createActionSheetButtons(data: HTMLIonSelectOptionElement[], selectValue: any): ActionSheetButton[] {
551+
console.log('createActionSheetButtons', data, selectValue);
551552
const actionSheetButtons = data.map((option) => {
552553
const value = getOptionValue(option);
553554

@@ -556,14 +557,18 @@ export class Select implements ComponentInterface {
556557
.filter((cls) => cls !== 'hydrated')
557558
.join(' ');
558559
const optClass = `${OPTION_CLASS} ${copyClasses}`;
560+
const isSelected = isOptionSelected(selectValue, value, this.compareWith);
559561

560562
return {
561-
role: isOptionSelected(selectValue, value, this.compareWith) ? 'selected' : '',
563+
role: isSelected ? 'selected' : '',
562564
text: option.textContent,
563565
cssClass: optClass,
564566
handler: () => {
565567
this.setValue(value);
566568
},
569+
htmlAttributes: {
570+
'aria-selected': isSelected ? 'true' : undefined,
571+
},
567572
} as ActionSheetButton;
568573
});
569574

0 commit comments

Comments
 (0)