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.
Цей коміт міститься в:
l0ng-ai committed 2026-11-27 08:54:03 +08:00
1 джерело 44338541b1
коміт a5eff28b68
2 files changed
+9 -3

No files matched your search

+1 -1
Переглянути файл
@@ -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);
+8 -2
Переглянути файл
@@ -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<DialogButtonRole, number> = { 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).
<div className={clsx(styles.titleBar, styles.macTitleBar)} data-dialog-drag="" data-dialog-titlebar="">
<span className={styles.title}>{title}</span>
</div>