diff --git a/core/src/components/alert/alert.tsx b/core/src/components/alert/alert.tsx index de8d7bd450d..27095b1326f 100644 --- a/core/src/components/alert/alert.tsx +++ b/core/src/components/alert/alert.tsx @@ -238,15 +238,6 @@ export class Alert implements ComponentInterface, OverlayInterface { onKeydown(ev: any) { const inputTypes = new Set(this.processedInputs.map((i) => i.type)); - /** - * Based on keyboard navigation requirements, the - * checkbox should not respond to the enter keydown event. - */ - if (inputTypes.has('checkbox') && ev.key === 'Enter') { - ev.preventDefault(); - return; - } - /** * Ensure when alert container is being focused, and the user presses the tab + shift keys, the focus will be set to the last alert button. */ @@ -525,6 +516,15 @@ export class Alert implements ComponentInterface, OverlayInterface { forceUpdate(this); } + /** + * Prevent Enter from toggling the checkbox, which only Space should do. + */ + private onCheckboxKeydown = (ev: KeyboardEvent) => { + if (ev.key === 'Enter') { + ev.preventDefault(); + } + }; + private async buttonClick(button: AlertButton) { const role = button.role; const values = this.getValues(); @@ -625,6 +625,7 @@ export class Alert implements ComponentInterface, OverlayInterface {