summaryrefslogtreecommitdiffhomepage
path: root/packages/desktop/src
diff options
context:
space:
mode:
authorSlone <[email protected]>2026-01-19 18:32:41 +0800
committerGitHub <[email protected]>2026-01-19 04:32:41 -0600
commit13276aee8255ea809a975dc70808af08273773f2 (patch)
tree5d6438e39daf41f6b8cd53dc385d72e1e66abccb /packages/desktop/src
parent4299450d7d474d350bd06b9e810a5d1250957a00 (diff)
downloadopencode-13276aee8255ea809a975dc70808af08273773f2.tar.gz
opencode-13276aee8255ea809a975dc70808af08273773f2.zip
fix(desktop): apply getComputedStyle polyfill on all platforms (#9369)
Diffstat (limited to 'packages/desktop/src')
-rw-r--r--packages/desktop/src/index.tsx21
1 files changed, 10 insertions, 11 deletions
diff --git a/packages/desktop/src/index.tsx b/packages/desktop/src/index.tsx
index 0d9e38379..6cd77d7d5 100644
--- a/packages/desktop/src/index.tsx
+++ b/packages/desktop/src/index.tsx
@@ -26,17 +26,16 @@ 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
-}
+// Floating UI can call getComputedStyle with non-elements (e.g., null refs, virtual elements).
+// This happens on all platforms (WebView2 on Windows, WKWebView on macOS), not just Windows.
+const originalGetComputedStyle = window.getComputedStyle
+window.getComputedStyle = ((elt: Element, pseudoElt?: string | null) => {
+ if (!(elt instanceof Element)) {
+ // Fall back to a safe element when a non-element is passed.
+ return originalGetComputedStyle(document.documentElement, pseudoElt ?? undefined)
+ }
+ return originalGetComputedStyle(elt, pseudoElt ?? undefined)
+}) as typeof window.getComputedStyle
let update: Update | null = null