From 8df0ff8c871a4ed263051dba2e872881f05997a8 Mon Sep 17 00:00:00 2001 From: Thomas Neumann Date: Thu, 29 Jan 2026 13:58:34 -0600 Subject: [PATCH] Fix non-modal dialog double close --- js/components/dcf-dialog.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/js/components/dcf-dialog.js b/js/components/dcf-dialog.js index db28b8c5..8b66880e 100644 --- a/js/components/dcf-dialog.js +++ b/js/components/dcf-dialog.js @@ -189,8 +189,15 @@ export default class DCFDialog { }); // Close dialog if we are no longer on it (this is important for the non-modal) - this.dialogElement.addEventListener('focusout', () => { - if (this.dialogElement.open) { + this.dialogElement.addEventListener('focusout', (event) => { + let isToggleButtonFocusout = false; + for (const singleToggleButton of this.toggleButtons) { + if (singleToggleButton.isSameNode(event.relatedTarget) || singleToggleButton.contains(event.relatedTarget)) { + isToggleButtonFocusout = true; + } + } + + if (this.dialogElement.open && !isToggleButtonFocusout) { requestAnimationFrame(() => { const active = document.activeElement; if (!this.dialogElement.contains(active)) {