Skip to content

Commit 9e24a0b

Browse files
feat(action-sheet, alert): add id to AlertButton and ActionSheetButton (#18992)
resolves #22959 Co-authored-by: Liam DeBeasi <[email protected]>
1 parent bdc1f23 commit 9e24a0b

20 files changed

+46
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ export interface ActionSheetButton {
2121
role?: 'cancel' | 'destructive' | 'selected' | string;
2222
icon?: string;
2323
cssClass?: string | string[];
24+
id?: string;
2425
handler?: () => boolean | void | Promise<boolean | void>;
2526
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export class ActionSheet implements ComponentInterface, OverlayInterface {
264264
</div>
265265
}
266266
{buttons.map(b =>
267-
<button type="button" class={buttonClass(b)} onClick={() => this.buttonClick(b)}>
267+
<button type="button" id={b.id} class={buttonClass(b)} onClick={() => this.buttonClick(b)}>
268268
<span class="action-sheet-button-inner">
269269
{b.icon && <ion-icon icon={b.icon} lazy={false} class="action-sheet-icon" />}
270270
{b.text}

core/src/components/action-sheet/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export class ActionSheetExample {
6363
text: 'Delete',
6464
role: 'destructive',
6565
icon: 'trash',
66+
id: 'delete-button',
6667
handler: () => {
6768
console.log('Delete clicked');
6869
}
@@ -120,6 +121,7 @@ async function presentActionSheet() {
120121
text: 'Delete',
121122
role: 'destructive',
122123
icon: 'trash',
124+
id: 'delete-button',
123125
handler: () => {
124126
console.log('Delete clicked');
125127
}
@@ -234,6 +236,7 @@ export const ActionSheetExample: React.FC = () => {
234236
text: 'Delete',
235237
role: 'destructive',
236238
icon: trash,
239+
id: 'delete-button',
237240
handler: () => {
238241
console.log('Delete clicked');
239242
}
@@ -291,6 +294,7 @@ export class ActionSheetExample {
291294
text: 'Delete',
292295
role: 'destructive',
293296
icon: 'trash',
297+
id: 'delete-button',
294298
handler: () => {
295299
console.log('Delete clicked');
296300
}
@@ -363,6 +367,7 @@ export default defineComponent({
363367
text: 'Delete',
364368
role: 'destructive',
365369
icon: trash,
370+
id: 'delete-button',
366371
handler: () => {
367372
console.log('Delete clicked')
368373
},

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
--ion-backdrop-opacity: 1;
5959
}
6060

61+
#delete-button {
62+
color: #eb445a;
63+
}
64+
6165
</style>
6266
<script>
6367
window.addEventListener('ionActionSheetDidDismiss', function (e) { console.log('didDismiss', e) })
@@ -75,6 +79,7 @@
7579
text: 'Delete',
7680
role: 'destructive',
7781
icon: 'trash',
82+
id: 'delete-button',
7883
handler: () => {
7984
console.log('Delete clicked');
8085
}

core/src/components/action-sheet/usage/angular.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export class ActionSheetExample {
1919
text: 'Delete',
2020
role: 'destructive',
2121
icon: 'trash',
22+
id: 'delete-button',
2223
handler: () => {
2324
console.log('Delete clicked');
2425
}

core/src/components/action-sheet/usage/javascript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ async function presentActionSheet() {
88
text: 'Delete',
99
role: 'destructive',
1010
icon: 'trash',
11+
id: 'delete-button',
1112
handler: () => {
1213
console.log('Delete clicked');
1314
}

core/src/components/action-sheet/usage/react.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export const ActionSheetExample: React.FC = () => {
7272
text: 'Delete',
7373
role: 'destructive',
7474
icon: trash,
75+
id: 'delete-button',
7576
handler: () => {
7677
console.log('Delete clicked');
7778
}

core/src/components/action-sheet/usage/stencil.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export class ActionSheetExample {
1616
text: 'Delete',
1717
role: 'destructive',
1818
icon: 'trash',
19+
id: 'delete-button',
1920
handler: () => {
2021
console.log('Delete clicked');
2122
}

core/src/components/action-sheet/usage/vue.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default defineComponent({
2121
text: 'Delete',
2222
role: 'destructive',
2323
icon: trash,
24+
id: 'delete-button',
2425
handler: () => {
2526
console.log('Delete clicked')
2627
},

core/src/components/alert/alert-interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ export interface AlertButton {
4646
text: string;
4747
role?: string;
4848
cssClass?: string | string[];
49+
id?: string;
4950
handler?: (value: any) => boolean | void | {[key: string]: any};
5051
}

core/src/components/alert/alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ export class Alert implements ComponentInterface, OverlayInterface {
538538
return (
539539
<div class={alertButtonGroupClass}>
540540
{buttons.map(button =>
541-
<button type="button" class={buttonClass(button)} tabIndex={0} onClick={() => this.buttonClick(button)}>
541+
<button type="button" id={button.id} class={buttonClass(button)} tabIndex={0} onClick={() => this.buttonClick(button)}>
542542
<span class="alert-button-inner">
543543
{button.text}
544544
</span>

core/src/components/alert/readme.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ export class AlertExample {
9999
text: 'Cancel',
100100
role: 'cancel',
101101
cssClass: 'secondary',
102+
id: 'cancel-button',
102103
handler: (blah) => {
103104
console.log('Confirm Cancel: blah');
104105
}
105106
}, {
106107
text: 'Okay',
108+
id: 'confirm-button',
107109
handler: () => {
108110
console.log('Confirm Okay');
109111
}
@@ -412,11 +414,13 @@ function presentAlertConfirm() {
412414
text: 'Cancel',
413415
role: 'cancel',
414416
cssClass: 'secondary',
417+
id: 'cancel-button',
415418
handler: (blah) => {
416419
console.log('Confirm Cancel: blah');
417420
}
418421
}, {
419422
text: 'Okay',
423+
id: 'confirm-button',
420424
handler: () => {
421425
console.log('Confirm Okay')
422426
}
@@ -759,12 +763,14 @@ export const AlertExample: React.FC = () => {
759763
text: 'Cancel',
760764
role: 'cancel',
761765
cssClass: 'secondary',
766+
id: 'cancel-button',
762767
handler: blah => {
763768
console.log('Confirm Cancel: blah');
764769
}
765770
},
766771
{
767772
text: 'Okay',
773+
id: 'confirm-button',
768774
handler: () => {
769775
console.log('Confirm Okay');
770776
}
@@ -1064,11 +1070,13 @@ export class AlertExample {
10641070
text: 'Cancel',
10651071
role: 'cancel',
10661072
cssClass: 'secondary',
1073+
id: 'cancel-button',
10671074
handler: (blah) => {
10681075
console.log('Confirm Cancel: blah');
10691076
}
10701077
}, {
10711078
text: 'Okay',
1079+
id: 'confirm-button',
10721080
handler: () => {
10731081
console.log('Confirm Okay');
10741082
}
@@ -1402,12 +1410,14 @@ export default defineComponent({
14021410
text: 'Cancel',
14031411
role: 'cancel',
14041412
cssClass: 'secondary',
1413+
id: 'cancel-button',
14051414
handler: blah => {
14061415
console.log('Confirm Cancel:', blah)
14071416
},
14081417
},
14091418
{
14101419
text: 'Okay',
1420+
id: 'confirm-button',
14111421
handler: () => {
14121422
console.log('Confirm Okay')
14131423
},

core/src/components/alert/test/basic/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
--min-width: 0;
4343
--max-width: 200px;
4444
}
45+
#delete-button {
46+
color: #eb445a;
47+
}
4548
</style>
4649
</ion-app>
4750

@@ -79,6 +82,7 @@
7982
'Open Modal',
8083
{
8184
text: 'Delete',
85+
id: 'delete-button',
8286
role: 'destructive',
8387
},
8488
'Cancel',
@@ -185,6 +189,7 @@
185189
text: 'Cancel',
186190
role: 'cancel',
187191
cssClass: 'secondary',
192+
id: 'cancel-id',
188193
handler: () => {
189194
console.log('Confirm Cancel')
190195
}

core/src/components/alert/test/standalone/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
text: 'Cancel',
186186
role: 'cancel',
187187
cssClass: 'secondary',
188+
id: 'cancel-id',
188189
handler: () => {
189190
console.log('Confirm Cancel')
190191
}

core/src/components/alert/test/translucent/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
text: 'Cancel',
166166
role: 'cancel',
167167
cssClass: 'secondary',
168+
id: 'cancel-id',
168169
handler: () => {
169170
console.log('Confirm Cancel')
170171
}

core/src/components/alert/usage/angular.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ export class AlertExample {
4848
text: 'Cancel',
4949
role: 'cancel',
5050
cssClass: 'secondary',
51+
id: 'cancel-button',
5152
handler: (blah) => {
5253
console.log('Confirm Cancel: blah');
5354
}
5455
}, {
5556
text: 'Okay',
57+
id: 'confirm-button',
5658
handler: () => {
5759
console.log('Confirm Okay');
5860
}

core/src/components/alert/usage/javascript.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ function presentAlertConfirm() {
3636
text: 'Cancel',
3737
role: 'cancel',
3838
cssClass: 'secondary',
39+
id: 'cancel-button',
3940
handler: (blah) => {
4041
console.log('Confirm Cancel: blah');
4142
}
4243
}, {
4344
text: 'Okay',
45+
id: 'confirm-button',
4446
handler: () => {
4547
console.log('Confirm Okay')
4648
}

core/src/components/alert/usage/react.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,14 @@ export const AlertExample: React.FC = () => {
9292
text: 'Cancel',
9393
role: 'cancel',
9494
cssClass: 'secondary',
95+
id: 'cancel-button',
9596
handler: blah => {
9697
console.log('Confirm Cancel: blah');
9798
}
9899
},
99100
{
100101
text: 'Okay',
102+
id: 'confirm-button',
101103
handler: () => {
102104
console.log('Confirm Okay');
103105
}

core/src/components/alert/usage/stencil.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ export class AlertExample {
4545
text: 'Cancel',
4646
role: 'cancel',
4747
cssClass: 'secondary',
48+
id: 'cancel-button',
4849
handler: (blah) => {
4950
console.log('Confirm Cancel: blah');
5051
}
5152
}, {
5253
text: 'Okay',
54+
id: 'confirm-button',
5355
handler: () => {
5456
console.log('Confirm Okay');
5557
}

core/src/components/alert/usage/vue.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ export default defineComponent({
5353
text: 'Cancel',
5454
role: 'cancel',
5555
cssClass: 'secondary',
56+
id: 'cancel-button',
5657
handler: blah => {
5758
console.log('Confirm Cancel:', blah)
5859
},
5960
},
6061
{
6162
text: 'Okay',
63+
id: 'confirm-button',
6264
handler: () => {
6365
console.log('Confirm Okay')
6466
},

0 commit comments

Comments
 (0)