From c226bfe7c4ce5b8bfdee0a2f0a741b9fe973f498 Mon Sep 17 00:00:00 2001 From: cuilanchao Date: Mon, 21 Sep 2026 09:51:28 +0800 Subject: [PATCH] fix: fix toolbar tooltip layout shift and hide native menu bar - Add CSS for .nexus-toolbar-tooltip with position:fixed to prevent document flow disruption - Add transform:translateX(-50%) for centered tooltip positioning - Add autoHideMenuBar:true to BrowserWindow to hide native menu bar (Alt to reveal) --- apps/electron-demo/electron/main.ts | 1 + apps/electron-demo/src/renderer/style.css | 14 ++++++++++++++ packages/plugin-toolbar/src/toolbar-ui.ts | 1 + 3 files changed, 16 insertions(+) diff --git a/apps/electron-demo/electron/main.ts b/apps/electron-demo/electron/main.ts index 22126b17..866be2f7 100644 --- a/apps/electron-demo/electron/main.ts +++ b/apps/electron-demo/electron/main.ts @@ -108,6 +108,7 @@ export function createWindow(options: CreateWindowOptions = {}): BrowserWindow { // the BrowserWindow is created, and the dock keeps bouncing until the // renderer reports first paint anyway. show: false, + autoHideMenuBar: true, backgroundColor: "#ffffff", webPreferences: { contextIsolation: true, diff --git a/apps/electron-demo/src/renderer/style.css b/apps/electron-demo/src/renderer/style.css index 652d837b..66460f63 100644 --- a/apps/electron-demo/src/renderer/style.css +++ b/apps/electron-demo/src/renderer/style.css @@ -343,3 +343,17 @@ body, color: var(--nexus-accent, #2563eb); font-weight: 500; } + +.nexus-toolbar-tooltip { + position: fixed; + z-index: 10000; + padding: 4px 8px; + border-radius: 4px; + background: var(--nexus-text, #24292e); + color: var(--nexus-bg, #fff); + font-size: 12px; + line-height: 1.4; + pointer-events: none; + white-space: nowrap; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); +} diff --git a/packages/plugin-toolbar/src/toolbar-ui.ts b/packages/plugin-toolbar/src/toolbar-ui.ts index a56ae862..9f8917aa 100644 --- a/packages/plugin-toolbar/src/toolbar-ui.ts +++ b/packages/plugin-toolbar/src/toolbar-ui.ts @@ -82,6 +82,7 @@ function positionToolbarTooltip(button: HTMLElement, tooltip: HTMLElement): void const rect = button.getBoundingClientRect(); tooltip.style.left = `${rect.left + rect.width / 2}px`; tooltip.style.top = `${rect.bottom + 8}px`; + tooltip.style.transform = "translateX(-50%)"; } function installToolbarTooltip(button: HTMLButtonElement): () => void {