Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(editor): close top-bar menus on a click on the empty bar
EtienneLescotc4c761b24848
diff --git a/src/components/ai-edition/v4/EditorShellV4.module.css b/src/components/ai-edition/v4/EditorShellV4.module.cssindex ee3d11fab..8188f58d9 100644--- a/src/components/ai-edition/v4/EditorShellV4.module.css+++ b/src/components/ai-edition/v4/EditorShellV4.module.css@@ -65,6 +65,14 @@-webkit-app-region: no-drag;app-region: no-drag;}+/* While a menu hanging off the bar is open (the wordmark's, the presets'), the bar stops being a+ titlebar. The OS takes a press on a drag region as a caption click and the page never sees it,+ so the outside-click that closes the menu missed every click on the empty bar (#1009). That+ click now closes the menu; the bar drags again from the next one. */+.topbar:has([aria-expanded="true"]) {+ -webkit-app-region: no-drag;+ app-region: no-drag;+}.sep {width: 1px;height: 18px;diff --git a/src/components/ai-edition/v4/EditorTopBar.stylePresets.test.tsx b/src/components/ai-edition/v4/EditorTopBar.stylePresets.test.tsxindex 896ef04ae..320438d1d 100644--- a/src/components/ai-edition/v4/EditorTopBar.stylePresets.test.tsx+++ b/src/components/ai-edition/v4/EditorTopBar.stylePresets.test.tsx@@ -3,6 +3,8 @@// catalog: the bridge, the settings hook, the platform and the toaster are the only fakes.import "@testing-library/jest-dom";+import { readFileSync } from "node:fs";+import path from "node:path";import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, type Mock, vi } from "vitest";import { TooltipProvider } from "@/components/ui/tooltip";@@ -469,3 +471,18 @@ describe("Presets menu in the editor top bar", () => {expect(state.set).not.toHaveBeenCalled();});});++// The other menu hanging off the bar: while it is open the bar stops being a window-drag region+// too, or a click on the empty bar never reaches the page to close it (#1009).+describe("Presets menu and the bar's drag region", () => {+ const css = readFileSync(path.join(__dirname, "EditorShellV4.module.css"), "utf8");+ const [, condition = ""] = css.match(/\n\.topbar(:has\([^{]*\))\s*\{/) ?? [];++ it("puts the bar under the no-drag rule while it is open", async () => {+ renderPane();+ const bar = screen.getByRole("button", { name: "Presets" }).closest("header") as HTMLElement;+ expect(bar.matches(condition)).toBe(false);+ await openMenu();+ expect(bar.matches(condition)).toBe(true);+ });+});diff --git a/src/components/ai-edition/v4/EditorTopBar.test.tsx b/src/components/ai-edition/v4/EditorTopBar.test.tsxindex f357f1121..f8a5a2e9c 100644--- a/src/components/ai-edition/v4/EditorTopBar.test.tsx+++ b/src/components/ai-edition/v4/EditorTopBar.test.tsx@@ -35,6 +35,7 @@ vi.mock("@/hooks/useTheme", () => ({useTheme: () => ({ theme: "dark", toggle: toggleTheme }),}));+import styles from "./EditorShellV4.module.css";import { EditorTopBar } from "./EditorTopBar";const noop = () => {};@@ -475,3 +476,28 @@ describe("AppMenu sizing (issue #969)", () => {expect(version).toMatch(/flex-shrink:\s*0/);});});++// jsdom has no window manager, so it cannot play the caption click that swallowed the press. What+// it can pin is the mechanism: the rule that drops the bar's drag region exists, and it matches the+// bar exactly while a menu hanging off it is open (#1009).+describe("top bar drag region while a menu is open (issue #1009)", () => {+ const css = readFileSync(path.join(__dirname, "EditorShellV4.module.css"), "utf8");+ const [, condition = "", body = ""] = css.match(/\n\.topbar(:has\([^{]*\))\s*\{([^}]*)\}/) ?? [];++ it("declares the bar no-drag under that condition", () => {+ expect(condition).not.toBe("");+ expect(body).toMatch(/-webkit-app-region:\s*no-drag/);+ expect(body).toMatch(/(^|\s)app-region:\s*no-drag/);+ });++ it("puts the bar under it only while the wordmark menu is open", () => {+ renderTopBar("Demo Project");+ const bar = document.querySelector(`header.${styles.topbar}`) as HTMLElement;+ expect(bar.matches(condition)).toBe(false);+ fireEvent.click(screen.getByRole("button", { name: /OpenScreen/ }));+ expect(bar.matches(condition)).toBe(true);+ fireEvent.mouseDown(bar);+ expect(screen.queryByRole("menu")).not.toBeInTheDocument();+ expect(bar.matches(condition)).toBe(false);+ });+});