Skip to content

Commit c150a61

Browse files
committed
refactor(action-sheet): update to accept dynamic roles
1 parent 626370b commit c150a61

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,15 @@ export class ActionSheet implements ComponentInterface, OverlayInterface {
9090
@Prop() buttons: (ActionSheetButton | string)[] = [];
9191
@Watch('buttons')
9292
buttonsChanged() {
93+
const radioButtons = this.getRadioButtons();
94+
this.hasRadioButtons = radioButtons.length > 0;
95+
9396
// Initialize activeRadioId when buttons change
9497
if (this.hasRadioButtons) {
95-
const allButtons = this.getButtons();
96-
const radioButtons = this.getRadioButtons();
9798
const checkedButton = radioButtons.find((b) => b.htmlAttributes?.['aria-checked'] === 'true');
99+
98100
if (checkedButton) {
101+
const allButtons = this.getButtons();
99102
const checkedIndex = allButtons.indexOf(checkedButton);
100103
this.activeRadioId = this.getButtonId(checkedButton, checkedIndex);
101104
}
@@ -439,8 +442,6 @@ export class ActionSheet implements ComponentInterface, OverlayInterface {
439442
connectedCallback() {
440443
prepareOverlay(this.el);
441444
this.triggerChanged();
442-
443-
this.hasRadioButtons = this.getButtons().some((b) => b.role === 'radio');
444445
}
445446

446447
disconnectedCallback() {

0 commit comments

Comments
 (0)