From f9cedd0295a5adfe477b7f58e3dc90acb307c326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dabiel=20Gonz=C3=A1lez=20Ramos?= Date: Mon, 1 Apr 2024 13:49:41 +0300 Subject: [PATCH] fix(Dialog): `disableCloseEscKeydown` still closing the dialog if enabled --- packages/beeq/src/components/dialog/bq-dialog.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/beeq/src/components/dialog/bq-dialog.tsx b/packages/beeq/src/components/dialog/bq-dialog.tsx index 0ec80d708..25ffeca63 100644 --- a/packages/beeq/src/components/dialog/bq-dialog.tsx +++ b/packages/beeq/src/components/dialog/bq-dialog.tsx @@ -143,8 +143,14 @@ export class BqDialog { } @Listen('keydown', { target: 'window', capture: true }) - async handleKeyDown(event: KeyboardEvent) { - if (!this.open || !this.dialogElem || !(event.key === 'Escape' || event.key === 'Esc')) return; + async handleKeyDown(ev: KeyboardEvent) { + const isEscapeKey = ev.key === 'Escape' || ev.key === 'Esc'; + if (!this.open || !this.dialogElem || !isEscapeKey) return; + + if (this.disableCloseEscKeydown) { + ev.preventDefault(); + return; + } await this.cancel(); } @@ -238,7 +244,7 @@ export class BqDialog { return (