From a5eff28b68a3bfe316f42932fee1405bff64aedc Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Fri, 27 Nov 2026 08:54:03 +0800 Subject: [PATCH] fix(ui): give a macOS dialog without footer buttons a Close button A sheet has no window buttons, so a dialog with neither buttons nor a footer could only be closed with Esc. The Extract Interface members table may shrink to two rows so the dialog still fits a short window under the taller sheet title. --- src/editor/refactor/ExtractInterfaceDialog.module.css | 2 +- src/ui/Dialog.tsx | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/editor/refactor/ExtractInterfaceDialog.module.css b/src/editor/refactor/ExtractInterfaceDialog.module.css index ac08618933..33129d137f 100644 --- a/src/editor/refactor/ExtractInterfaceDialog.module.css +++ b/src/editor/refactor/ExtractInterfaceDialog.module.css @@ -44,7 +44,7 @@ .table { flex: 1; - min-height: calc(var(--h-list-row) * 3); + min-height: calc(var(--h-list-row) * 2); overflow: auto; scrollbar-gutter: stable; scroll-padding-top: var(--h-list-row); diff --git a/src/ui/Dialog.tsx b/src/ui/Dialog.tsx index a4c46d5281..dedcbd6829 100644 --- a/src/ui/Dialog.tsx +++ b/src/ui/Dialog.tsx @@ -43,6 +43,8 @@ export function useDialogPlatform(override?: DialogPlatform): DialogPlatform { return override ?? dialogPlatformOf(os); } +const MAC_CLOSE_BUTTONS: readonly DialogButton[] = [{ label: "Close", role: "cancel" }]; + const MAC_ORDER: Record = { cancel: -10, extra: 0, default: 100 }; /** @@ -216,7 +218,7 @@ function DialogInner({ blockWorkbenchShortcuts = false, title, children, - buttons, + buttons: givenButtons, footerStart, onHelp, footer, @@ -243,6 +245,10 @@ function DialogInner({ const given = useGivenTx(); if (typeof title === "string") title = given(title); const popup = asPopup || position === "top" || (title == null && !icon); + // A macOS sheet has no close button of its own: one without footer buttons gets a Close button + // so it can still be closed with the mouse. + const buttons = + platform === "mac" && !popup && !icon && !givenButtons?.length && !footer ? MAC_CLOSE_BUTTONS : givenButtons; const onCloseRef = useRef(onClose); const buttonsRef = useRef(buttons); const restoreFocusRef = useRef(restoreFocus); @@ -462,7 +468,7 @@ 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). + // window buttons of its own (Esc and Cancel or Close close it).
{title}