TypeScript
fix(desktop): tooltips no longer open under the macOS traffic lights (#17726)
oliver662148dd2969
diff --git a/apps/web/src/lib/windowControlsOverlay.ts b/apps/web/src/lib/windowControlsOverlay.tsindex 6508ebc4a0e..24f179f6cb9 100644--- a/apps/web/src/lib/windowControlsOverlay.ts+++ b/apps/web/src/lib/windowControlsOverlay.ts@@ -1,10 +1,15 @@import { useSyncExternalStore } from "react";-import { isWindowsPlatform } from "./utils";+import { isElectron } from "~/env";++import { isMacPlatform, isWindowsPlatform } from "./utils";const WCO_CLASS_NAME = "wco";const ELECTRON_CLASS_NAME = "electron";const ELECTRON_WINDOWS_CLASS_NAME = "electron-windows";+// The workspace topbar the desktop app centers the traffic lights in. macOS has+// no overlay API to measure, and the lights stay inside it at any zoom level.+const MACOS_TITLEBAR_HEIGHT = 52;interface WindowControlsOverlayLike {readonly visible: boolean;@@ -53,6 +58,7 @@ function subscribeTitlebarArea(listener: () => void): () => void {}function getNativeTitlebarHeight(): number {+ if (isElectron && isMacPlatform(navigator.platform)) return MACOS_TITLEBAR_HEIGHT;const overlay = getWindowControlsOverlay();return overlay?.visible ? overlay.getTitlebarAreaRect().bottom : 0;}