From fe5735724fcf4ab3bbf128ce793e2a37ec16067a Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Tue, 7 Nov 2023 09:08:09 +1030 Subject: [PATCH] fix(modal): fall back to default focus strategy if there is no autofocus element --- src/modal/modal.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modal/modal.ts b/src/modal/modal.ts index 19de845..8120211 100644 --- a/src/modal/modal.ts +++ b/src/modal/modal.ts @@ -43,7 +43,8 @@ export default class ModalElement extends HTMLElement { escapeDeactivates: false, allowOutsideClick: true, preventScroll: true, - initialFocus: () => this.querySelector('[autofocus]'), + initialFocus: () => + this.querySelector('[autofocus]') || undefined, }); }