From 3a9b79b04fa8064a19e6003d8bf8a246d0339670 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Mon, 9 Nov 2026 15:28:59 -0800 Subject: [PATCH] fix(ui): drop modal blur when the overlay starts closing The workspace blur was keyed on the overlay node existing, so it held through Radix's exit fade and snapped off after the dim was already gone. --- src/renderer/src/assets/main.css | 4 +++- src/renderer/src/lib/body-overlay-attributes.ts | 14 ++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/assets/main.css index 59c6fd15fb5..47b8935c749 100644 --- a/src/renderer/src/assets/main.css +++ b/src/renderer/src/assets/main.css @@ -1059,7 +1059,9 @@ body[data-modal-overlay-open] [data-slot='command-dialog-content'], [data-slot='sheet-content'], [data-onboarding-overlay] - ):has(~ [data-slot='dialog-overlay'], ~ [data-slot='sheet-overlay']) { + ):has( + ~ :is([data-slot='dialog-overlay'], [data-slot='sheet-overlay']):not([data-state='closed']) + ) { filter: blur(2px); } diff --git a/src/renderer/src/lib/body-overlay-attributes.ts b/src/renderer/src/lib/body-overlay-attributes.ts index 39c85bc90b8..a34733b8be4 100644 --- a/src/renderer/src/lib/body-overlay-attributes.ts +++ b/src/renderer/src/lib/body-overlay-attributes.ts @@ -1,5 +1,7 @@ -export const MODAL_OVERLAY_CHILD_SELECTOR = - ":scope > [data-slot='dialog-overlay'], :scope > [data-slot='sheet-overlay']" +const MOUNTED_MODAL_OVERLAY_CHILD_SELECTOR = + ":scope > :is([data-slot='dialog-overlay'], [data-slot='sheet-overlay'])" +// Radix keeps a closing overlay mounted through its fade; it must not hold the blur past the dim. +export const MODAL_OVERLAY_CHILD_SELECTOR = `${MOUNTED_MODAL_OVERLAY_CHILD_SELECTOR}:not([data-state='closed'])` const ONBOARDING_OVERLAY_CHILD_SELECTOR = ':scope > [data-onboarding-overlay]' let disposeInstalledObserver: (() => void) | null = null @@ -11,7 +13,11 @@ export function installBodyOverlayAttributes(): () => void { return disposeInstalledObserver } const body = document.body + const observer = new MutationObserver(() => sync()) const sync = (): void => { + for (const overlay of body.querySelectorAll(MOUNTED_MODAL_OVERLAY_CHILD_SELECTOR)) { + observer.observe(overlay, { attributes: true, attributeFilter: ['data-state'] }) + } // toggleAttribute is a no-op when the state is unchanged, so unrelated portals cost no restyle. body.toggleAttribute( 'data-modal-overlay-open', @@ -23,8 +29,8 @@ export function installBodyOverlayAttributes(): () => void { ) } sync() - // Overlays portal as direct body children; childList-only keeps the callback off app mutations. - const observer = new MutationObserver(sync) + // Overlays portal as direct body children; watching only body children and overlay state keeps + // the callback off app mutations. observer.observe(body, { childList: true }) disposeInstalledObserver = () => { observer.disconnect()