From 5036a4fd74d054e3c2dec3367e2bcd1f1d8f0b59 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Thu, 12 Oct 2023 12:04:24 +1030 Subject: [PATCH] fix(modal): activate focus trap reliably at start of transition --- src/modal/modal.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modal/modal.ts b/src/modal/modal.ts index 54ce555..19de845 100644 --- a/src/modal/modal.ts +++ b/src/modal/modal.ts @@ -117,9 +117,10 @@ export default class ModalElement extends HTMLElement { private async wasOpened() { this.hidden = false; - await hello(this); - this.focusTrap?.activate(); + hello(this); + + requestAnimationFrame(() => this.focusTrap?.activate()); this.dispatchEvent(new Event('open')); }