Skip to content

Commit 4d522b9

Browse files
committed
fix(alert): Add comment to give context about why this approach has been implemented.
1 parent 1909e03 commit 4d522b9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/src/components/alert/alert.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,13 @@ export class Alert implements ComponentInterface, OverlayInterface {
413413
await this.delegateController.attachViewToDom();
414414

415415
await present(this, 'alertEnter', iosEnterAnimation, mdEnterAnimation).then(() => {
416+
/**
417+
* Check if alert has only one button and no inputs.
418+
* If so, focus the button, oderwise focus the alert wrapper.
419+
* This will map to the default native alert behavior.
420+
*/
416421
if (this.buttons.length === 1 && this.inputs.length === 0) {
417422
const queryBtn = this.wrapperEl?.querySelector('.alert-button') as HTMLButtonElement;
418-
419423
queryBtn.focus();
420424
} else {
421425
this.wrapperEl?.focus();

0 commit comments

Comments
 (0)