From 44338541b1ebf8d4955ca24b879a63d095e35982 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Thu, 26 Nov 2026 23:04:24 +0800 Subject: [PATCH] feat(ui): show dialogs in the page as sheets without window buttons on macOS The title heads the content instead of a title bar with drawn traffic lights; Esc and Cancel close the dialog, and the title dims while the window is inactive. --- .../vcs/__tests__/diffDialog.test.tsx | 2 +- src/ui/Dialog.module.css | 60 +++---------------- src/ui/Dialog.test.tsx | 9 +-- src/ui/Dialog.tsx | 16 +---- 4 files changed, 15 insertions(+), 72 deletions(-) diff --git a/src/features/vcs/__tests__/diffDialog.test.tsx b/src/features/vcs/__tests__/diffDialog.test.tsx index 24b22c6e69..63f2ee0743 100644 --- a/src/features/vcs/__tests__/diffDialog.test.tsx +++ b/src/features/vcs/__tests__/diffDialog.test.tsx @@ -172,7 +172,7 @@ describe("Commit dialog diff window (#1863)", () => { ? "[data-testid='diff-view']" : location === "footer" ? "[data-dialog-footer] button" - : "[data-dialog-titlebar] button", + : "[data-dialog-titlebar]", )!; fireEvent.keyDown(target, { key: "w", code: "KeyW", metaKey: true }); expect(closeTab).not.toHaveBeenCalled(); diff --git a/src/ui/Dialog.module.css b/src/ui/Dialog.module.css index 632a8e5af0..2c8ee0b2e7 100644 --- a/src/ui/Dialog.module.css +++ b/src/ui/Dialog.module.css @@ -83,9 +83,8 @@ touch-action: none; } .macTitleBar { - height: var(--h-dialog-titlebar-mac, 28px); - padding: 0 12px 0 8px; - gap: var(--space-3); + height: var(--h-dialog-titlebar-mac, 40px); + padding: 0 var(--space-4); } .popupHeader { height: 32px; @@ -107,54 +106,9 @@ .macTitleBar .title { font-size: var(--fs-ui); } - -/* NSWindow standard buttons: 12px, 8px apart; close red, minimise / zoom disabled (modal). */ -.lights { - flex: none; - display: inline-flex; - gap: var(--space-2); -} -.light { - position: relative; - width: 12px; - height: 12px; - padding: 0; - display: inline-flex; - align-items: center; - justify-content: center; - border-radius: 50%; - background: var(--traffic-off); - box-shadow: inset 0 0 0 0.5px var(--traffic-off-border); - cursor: default; -} -.lightClose { - background: var(--traffic-close); - box-shadow: inset 0 0 0 0.5px var(--traffic-close-border); -} -[data-inactive] .lightClose { - background: var(--traffic-off); - box-shadow: inset 0 0 0 0.5px var(--traffic-off-border); -} -.lightGlyph { - --icon-color: var(--traffic-glyph); - color: var(--traffic-glyph); - opacity: 0; -} -.lights:hover .lightClose, -.lightClose:focus-visible { - background: var(--traffic-close); - box-shadow: inset 0 0 0 0.5px var(--traffic-close-border); -} -.lights:hover .lightGlyph, -.lightClose:focus-visible .lightGlyph { - opacity: 1; -} -.lightClose:active { - background: var(--traffic-close-pressed); -} -.lightClose:focus-visible { - outline: 2px solid var(--focus-ring); - outline-offset: 1px; +/* An inactive window's title dims, as AppKit's does. */ +[data-inactive] .macTitleBar .title { + color: var(--fg-muted); } .body { @@ -187,6 +141,10 @@ gap: var(--space-3); padding: 12px 16px; } +/* macOS: the buttons sit in the content's corner, as in the dialog windows. */ +[data-platform="mac"] > .footer:not(.messageFooter) { + padding-bottom: var(--space-4); +} .footerStart { flex: 1 1 0; min-width: fit-content; diff --git a/src/ui/Dialog.test.tsx b/src/ui/Dialog.test.tsx index 0c3a08ff37..92b0d0e531 100644 --- a/src/ui/Dialog.test.tsx +++ b/src/ui/Dialog.test.tsx @@ -64,17 +64,14 @@ describe("Dialog chrome", () => { , ); - it("macOS: traffic lights (only close enabled), title after them, Cancel … default rightmost", () => { + it("macOS: a sheet titled in its content, no window buttons, Cancel … default rightmost", () => { const onClose = vi.fn(); show("mac", onClose); const bar = document.querySelector("[data-dialog-titlebar]") as HTMLElement; - const lights = within(bar).getAllByRole("button"); - expect(lights.map((b) => b.getAttribute("aria-label"))).toEqual(["Close", "Minimize", "Zoom"]); - expect(lights[1]).toBeDisabled(); - expect(lights[2]).toBeDisabled(); + expect(within(bar).queryAllByRole("button")).toEqual([]); expect(bar.textContent).toBe("Usages Detected"); expect(footerLabels()).toEqual(["Cancel", "Delete Anyway", "View Usages"]); - fireEvent.click(lights[0]!); + fireEvent.keyDown(document.activeElement ?? document.body, { key: "Escape" }); expect(onClose).toHaveBeenCalledTimes(1); }); diff --git a/src/ui/Dialog.tsx b/src/ui/Dialog.tsx index f1cd6323f1..a4c46d5281 100644 --- a/src/ui/Dialog.tsx +++ b/src/ui/Dialog.tsx @@ -3,7 +3,6 @@ import { createPortal } from "react-dom"; import clsx from "clsx"; import { usePlatform } from "@/platform/platformInfo"; import { Button, IconButton } from "./Button"; -import { Icon } from "./icons"; import { FOCUSABLE, dismissPopups, onWindowDeactivate, openLayer, trapTab } from "./popupState"; import { PopupAncestry } from "./Popup"; import { tx, useGivenTx } from "@/platform/i18n"; @@ -462,20 +461,9 @@ function DialogInner({ ) ) : platform === "mac" ? ( + // A sheet over the window, as the dialog windows look: the title heads the content, no + // window buttons of its own (Esc and Cancel close it).