From cccb1b9c5fbbfc60213aa98cbfd6afba8a43baa0 Mon Sep 17 00:00:00 2001 From: Eric-Guo Date: Sat, 17 Jan 2026 12:25:47 +0800 Subject: [PATCH] Added a Windows-only guard that makes window.getComputedStyle fall back to document.documentElement when a non-Element slips through, which prevents Floating UI (used by Kobalte tooltips/popovers) from throwing in WebView2 after message submit. --- packages/desktop/src/index.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/desktop/src/index.tsx b/packages/desktop/src/index.tsx index 7a46ba8cde0..8398f457766 100644 --- a/packages/desktop/src/index.tsx +++ b/packages/desktop/src/index.tsx @@ -26,6 +26,18 @@ if (import.meta.env.DEV && !(root instanceof HTMLElement)) { ) } +const isWindows = ostype() === "windows" +if (isWindows) { + const originalGetComputedStyle = window.getComputedStyle + window.getComputedStyle = ((elt: Element, pseudoElt?: string | null) => { + if (!(elt instanceof Element)) { + // WebView2 can call into Floating UI with non-elements; fall back to a safe element. + return originalGetComputedStyle(document.documentElement, pseudoElt ?? undefined) + } + return originalGetComputedStyle(elt, pseudoElt ?? undefined) + }) as typeof window.getComputedStyle +} + let update: Update | null = null const createPlatform = (password: Accessor): Platform => ({