Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(ok): keep the window draggable while a dialog is open (#3786)

sarah9eb4e1cecae4
diff --git a/.changeset/dialog-window-drag-band.md b/.changeset/dialog-window-drag-band.md
new file mode 100644
index 000000000..af3f99e35
--- /dev/null
+++ b/.changeset/dialog-window-drag-band.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Every dialog now leaves the window movable. Reaching for the title bar while a dialog was open used to count as a click outside it, so the dialog closed instead of the window moving — and there was no way to drag the window at all without answering the dialog first. The title-bar band stays draggable behind the backdrop now, and dialogs are held clear of it, so the band never covers a dialog's own heading or buttons. The top edge of the screen no longer dismisses a dialog on click; Escape, the close button, and the rest of the backdrop still do.
diff --git a/packages/app/src/components/AppMenubar.dom.test.tsx b/packages/app/src/components/AppMenubar.dom.test.tsx
index 08aa730ac..1521cc300 100644
--- a/packages/app/src/components/AppMenubar.dom.test.tsx
+++ b/packages/app/src/components/AppMenubar.dom.test.tsx
@@ -243,3 +243,25 @@ describe('AppMenubar View terminal toggle', () => {
expect(screen.queryByRole('menuitem', { name: /Hide Terminal/ })).toBeNull();
});
});
+
+describe('AppMenubar drag-suspension attributes', () => {
+ afterEach(() => {
+ cleanup();
+ (window as unknown as { okDesktop?: unknown }).okDesktop = undefined;
+ });
+
+ test('open menu content matches the globals.css drag-suspension selector', async () => {
+ // `globals.css` suspends the Electron drag band while a floater is open by
+ // matching `[data-slot="menubar-content"][data-state="open"]`. AppMenubar
+ // renders INTO a chrome row that is itself a drag region, so if either
+ // attribute stops being emitted the selector goes inert and the menu
+ // cannot be dismissed by clicking the row it hangs from. jsdom cannot
+ // evaluate `:has()`, but it can pin the attributes it keys off.
+ installBridge('win32');
+ await openMenu('View');
+
+ const content = document.querySelector('[data-slot="menubar-content"]');
+ expect(content).toBeTruthy();
+ expect(content?.getAttribute('data-state')).toBe('open');
+ });
+});
diff --git a/packages/app/src/components/settings/SettingsDialogShell.dom.test.tsx b/packages/app/src/components/settings/SettingsDialogShell.dom.test.tsx
index d764ca236..63e8d6b9d 100644
--- a/packages/app/src/components/settings/SettingsDialogShell.dom.test.tsx
+++ b/packages/app/src/components/settings/SettingsDialogShell.dom.test.tsx
@@ -24,6 +24,10 @@ import type { ConfigBinding, OkignoreBinding } from '@inkeep/open-knowledge-core
import { act, cleanup, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
+import {
+ expectVisualClassTokens,
+ expectVisualClassTokensAbsent,
+} from '@/test-utils/visual-contract';
// Radix UI primitives (used by shadcn `Dialog`) reach for DOM globals at
// mount time that `tests/dom/jsdom-preload.ts` does not expose. Hoist the
@@ -396,4 +400,30 @@ describe('SettingsDialogShell userBinding gating (Tier-3 mount)', () => {
expect(screen.getByTestId('settings-dialog')).toBeTruthy();
expect(screen.getByRole('navigation', { name: 'Settings sections' })).toBeTruthy();
});
+
+ test('keeps its own 4rem height cap in the browser', () => {
+ render(<SettingsDialogShell open={true} onOpenChange={() => {}} />);
+
+ const className = screen.getByTestId('settings-dialog').getAttribute('class');
+ expectVisualClassTokens(className, ['max-h-[calc(100dvh-4rem)]']);
+ expectVisualClassTokensAbsent(className, ['max-h-[calc(100dvh-6rem)]']);
+ expect(screen.queryByTestId('dialog-drag-strip')).toBeNull();
+ });
+
+ test('yields to the drag-band clearance on the desktop host', () => {
+ // The shell reads `okDesktop.config` during render, so the host stub needs
+ // more shape than the drag-band gate itself looks at.
+ vi.stubGlobal('okDesktop', { config: { ptyAvailable: false } });
+ try {
+ render(<SettingsDialogShell open={true} onOpenChange={() => {}} />);
+
+ // Its own 4rem cap would leave the dialog 16px under the 3rem band.
+ const className = screen.getByTestId('settings-dialog').getAttribute('class');
+ expectVisualClassTokens(className, ['max-h-[calc(100dvh-6rem)]']);
+ expectVisualClassTokensAbsent(className, ['max-h-[calc(100dvh-4rem)]']);
+ expect(screen.getByTestId('dialog-drag-strip')).toBeTruthy();
+ } finally {
+ vi.unstubAllGlobals();
+ }
+ });
});
diff --git a/packages/app/src/components/settings/SettingsDialogShell.tsx b/packages/app/src/components/settings/SettingsDialogShell.tsx
index 0f948d624..9f0dca178 100644
--- a/packages/app/src/components/settings/SettingsDialogShell.tsx
+++ b/packages/app/src/components/settings/SettingsDialogShell.tsx
@@ -55,6 +55,7 @@ import {
CommandList,
} from '@/components/ui/command';
import { Dialog, DialogContent, DialogDescription, DialogTitle } from '@/components/ui/dialog';
+import { electronDragBandClearance } from '@/components/ui/electron-drag-strip';
import { Skeleton } from '@/components/ui/skeleton';
import { useDocumentContext } from '@/editor/DocumentContext';
import { useConfigContext } from '@/lib/config-provider';
@@ -368,7 +369,13 @@ export function SettingsDialogShell({
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent
- className="flex h-[700px] max-h-[calc(100dvh-4rem)] w-[900px] max-w-[calc(100%-2rem)] flex-col gap-0 overflow-hidden p-0 sm:grid sm:grid-cols-[220px_1fr] sm:max-w-[min(900px,calc(100%-2rem))]"
+ // Own max-h, so DialogContent's drag-band clearance loses to it by
+ // cn() precedence — re-applied here, last, to win back on the desktop
+ // host. In the browser it is a no-op and the 4rem cap stands.
+ className={cn(
+ 'flex h-[700px] max-h-[calc(100dvh-4rem)] w-[900px] max-w-[calc(100%-2rem)] flex-col gap-0 overflow-hidden p-0 sm:grid sm:grid-cols-[220px_1fr] sm:max-w-[min(900px,calc(100%-2rem))]',
+ electronDragBandClearance(),
+ )}
data-testid="settings-dialog"
>
<DialogTitle className="sr-only">
diff --git a/packages/app/src/components/ui/alert-dialog.dom.test.tsx b/packages/app/src/components/ui/alert-dialog.dom.test.tsx
index a7fc5f14e..835553455 100644
--- a/packages/app/src/components/ui/alert-dialog.dom.test.tsx
+++ b/packages/app/src/components/ui/alert-dialog.dom.test.tsx
@@ -14,7 +14,10 @@
import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { afterEach, describe, expect, test, vi } from 'vitest';
-import { expectVisualClassTokens } from '@/test-utils/visual-contract';
+import {
+ expectVisualClassTokens,
+ expectVisualClassTokensAbsent,
+} from '@/test-utils/visual-contract';
import {
AlertDialog,
AlertDialogAction,
@@ -324,6 +327,20 @@ describe('AlertDialog surface classes', () => {
}
});
+ test('clamps the dialog clear of the band on the desktop host', () => {
+ vi.stubGlobal('okDesktop', {});
+ try {
+ renderAlert();
+
+ const className = screen.getByRole('alertdialog').getAttribute('class') ?? '';
+ // Twice the 3rem band, because the dialog is vertically centered.
+ expectVisualClassTokens(className, ['max-h-[calc(100dvh-6rem)]']);
+ expectVisualClassTokensAbsent(className, ['max-h-[calc(100dvh-2rem)]']);
+ } finally {
+ vi.unstubAllGlobals();
+ }
+ });
+
test('caller className composes with the base classes rather than replacing them', () => {
render(
<AlertDialog open>
diff --git a/packages/app/src/components/ui/alert-dialog.tsx b/packages/app/src/components/ui/alert-dialog.tsx
index 9216f89a4..2a2932806 100644
--- a/packages/app/src/components/ui/alert-dialog.tsx
+++ b/packages/app/src/components/ui/alert-dialog.tsx
@@ -1,6 +1,7 @@
import { AlertDialog as AlertDialogPrimitive } from 'radix-ui';
import type * as React from 'react';
import { Button } from '@/components/ui/button';
+import { ElectronDragStrip, electronDragBandClearance } from '@/components/ui/electron-drag-strip';
import { cn } from '@/lib/utils';
/**
@@ -25,6 +26,10 @@ import { cn } from '@/lib/utils';
* pointer events over the OS titlebar drag region are swallowed by the
* window-drag handler, so a dialog anchored near the top of the Electron
* window becomes unclickable. Same reasoning as `dialog.tsx`.
+ * - The registry component has no title-bar drag affordance, so an open
+ * dialog would leave the window immovable. `ElectronDragStrip` and
+ * `electronDragBandClearance` are shared with `dialog.tsx` — behavior with
+ * a DOM-position invariant, not styling, so it lives in one place.
* - The registry component omits the `motion-reduce:*` opt-outs, so it
* animates through `prefers-reduced-motion`.
* - The registry title uses a `cn-font-heading` token that does not exist in
@@ -70,46 +75,6 @@ function AlertDialogOverlay({
);
}
-/**
- * Hands the title-bar band back to the window while an alert dialog is open.
- *
- * `AlertDialogOverlay` blankets the viewport with `-webkit-app-region: no-drag`,
- * which also neutralizes the chrome-row drag regions underneath it — so an open
- * alert dialog leaves an Electron window immovable until it is answered.
- * Painting a `drag` strip over that band restores it.
- *
- * MUST stay between the overlay and the content, at the same z-index as both.
- * App-region resolves topmost-first and equal-z positioned elements paint in DOM
- * order, so that one position is what lets the strip beat the overlay while
- * still losing to the dialog itself. Moved above the content, it would turn the
- * top of a viewport-tall dialog — its heading, any header control — into a drag
- * region and swallow those clicks, which is the exact failure `no-drag` on the
- * content exists to prevent.
- *
- * `pointer-events-none` keeps the strip out of DOM hit-testing while
- * `-webkit-app-region` still resolves at the compositor — the same pairing the
- * editor-window chrome strip uses. `data-electron-drag` opts it into the
- * `globals.css` rule that suspends drag while a popper floater is open, so a
- * menu opened from inside the dialog stays dismissable by clicking the band.
- *
- * Deliberately not offered on plain `Dialog`, which dismisses on outside click:
- * a drag region swallows that gesture for the pixels it covers, and dialogs that
- * dismiss differently depending on which one you opened is a worse trade than a
- * window you cannot move. An alert dialog has no outside-click dismissal to lose
- * (Radix preventDefaults it), so the strip costs it nothing.
- */
-function AlertDialogDragStrip() {
- if (typeof window === 'undefined' || window.okDesktop == null) return null;
- return (
- <div
- aria-hidden="true"
- data-testid="alert-dialog-drag-strip"
- data-electron-drag=""
- className="pointer-events-none fixed inset-x-0 top-0 z-50 h-12 [-webkit-app-region:drag]"
- />
- );
-}
-
function AlertDialogContent({
className,
...props
@@ -117,8 +82,8 @@ function AlertDialogContent({
return (
<AlertDialogPortal>
<AlertDialogOverlay />
- {/* Between overlay and content, deliberately — see AlertDialogDragStrip. */}
- <AlertDialogDragStrip />
+ {/* Between overlay and content, deliberately — see ElectronDragStrip. */}
+ <ElectronDragStrip testId="alert-dialog-drag-strip" />
<AlertDialogPrimitive.Content
data-slot="alert-dialog-content"
// No close affordance in the corner, by design: an alert dialog offers
@@ -127,6 +92,7 @@ function AlertDialogContent({
// scrolling lives in AlertDialogBody, the footer stays pinned.
className={cn(
'fixed top-1/2 left-1/2 z-50 flex w-full max-w-[calc(100%-2rem)] max-h-[calc(100dvh-2rem)] -translate-x-1/2 -translate-y-1/2 flex-col gap-6 overflow-hidden rounded-xl bg-popover p-6 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm [-webkit-app-region:no-drag] data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0',
+ electronDragBandClearance(),
className,
)}
{...props}
diff --git a/packages/app/src/components/ui/dialog.dom.test.tsx b/packages/app/src/components/ui/dialog.dom.test.tsx
index 4533aca5b..4f9ef5c49 100644
--- a/packages/app/src/components/ui/dialog.dom.test.tsx
+++ b/packages/app/src/components/ui/dialog.dom.test.tsx
@@ -1,5 +1,5 @@
import * as actualLinguiMacro from '@lingui/react/macro';
-import { cleanup, render } from '@testing-library/react';
+import { cleanup, render, screen } from '@testing-library/react';
import type { ReactNode } from 'react';
import { afterEach, describe, expect, test, vi } from 'vitest';
import {
@@ -117,3 +117,102 @@ describe('Dialog runtime class contracts', () => {
expectVisualClassTokensAbsent(surfaces, SNAPPY_TOKENS);
});
});
+
+describe('Dialog window-drag band', () => {
+ afterEach(() => {
+ cleanup();
+ vi.unstubAllGlobals();
+ });
+
+ test('renders no drag strip and no extra clearance off the desktop host', async () => {
+ await renderDialogContent();
+
+ expect(screen.queryByTestId('dialog-drag-strip')).toBeNull();
+ expectVisualClassTokens(
+ document.querySelector('[data-slot="dialog-content"]')?.getAttribute('class'),
+ ['max-h-[calc(100dvh-2rem)]'],
+ );
+ });
+
+ test('restores the title-bar drag band, between the overlay and the dialog', async () => {
+ vi.stubGlobal('okDesktop', {});
+ await renderDialogContent();
+
+ const strip = screen.getByTestId('dialog-drag-strip');
+ const overlay = document.querySelector('[data-slot="dialog-overlay"]');
+ const content = document.querySelector('[data-slot="dialog-content"]');
+
+ expectVisualClassTokens(strip.getAttribute('class'), [
+ '[-webkit-app-region:drag]',
+ 'pointer-events-none',
+ 'h-12',
+ 'z-50',
+ ]);
+ // The ordering IS the contract: after the overlay so it beats the no-drag
+ // blanket, before the content so the close X and heading of a dialog that
+ // overlaps the band stay clickable rather than becoming drag region.
+ expect(overlay?.compareDocumentPosition(strip)).toBe(Node.DOCUMENT_POSITION_FOLLOWING);
+ expect(content?.compareDocumentPosition(strip)).toBe(Node.DOCUMENT_POSITION_PRECEDING);
+ // Opts into the globals.css rule that suspends drag under an open popper.
+ expect(strip.hasAttribute('data-electron-drag')).toBe(true);
+ expect(strip.getAttribute('aria-hidden')).toBe('true');
+ });
+
+ test('clamps the dialog clear of the band on the desktop host', async () => {
+ vi.stubGlobal('okDesktop', {});
+ await renderDialogContent();
+
+ const className =
+ document.querySelector('[data-slot="dialog-content"]')?.getAttribute('class') ?? '';
+ // Twice the 3rem band, because the dialog is vertically centered.
+ expectVisualClassTokens(className, ['max-h-[calc(100dvh-6rem)]']);
+ expectVisualClassTokensAbsent(className, ['max-h-[calc(100dvh-2rem)]']);
+ });
+
+ test('a Dialog hosting an AlertDialog yields two distinct strips', async () => {
+ // Real path: Settings hosts a delete-confirmation AlertDialog. The per-
+ // surface testId exists for exactly this composition — a hardcoded id
+ // would collide here and getByTestId would throw on the duplicate.
+ vi.stubGlobal('okDesktop', {});
+ const { Dialog, DialogContent, DialogTitle } = await import('./dialog');
+ const { AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogTitle } = await import(
+ './alert-dialog'
+ );
+
+ render(
+ <Dialog open={true}>
+ <DialogContent showCloseButton={false}>
+ <DialogTitle>Outer</DialogTitle>
+ <AlertDialog open={true}>
+ <AlertDialogContent>
+ <AlertDialogTitle>Inner</AlertDialogTitle>
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
+ </AlertDialogContent>
+ </AlertDialog>
+ </DialogContent>
+ </Dialog>,
+ );
+
+ const outer = screen.getByTestId('dialog-drag-strip');
+ const inner = screen.getByTestId('alert-dialog-drag-strip');
+ expect(outer).not.toBe(inner);
+ });
+
+ test('a caller max-h still wins over the clearance clamp', async () => {
+ vi.stubGlobal('okDesktop', {});
+ const { Dialog, DialogContent, DialogTitle } = await import('./dialog');
+
+ render(
+ <Dialog open={true}>
+ <DialogContent showCloseButton={false} className="max-h-[20rem]">
+ <DialogTitle>Dialog title</DialogTitle>
+ </DialogContent>
+ </Dialog>,
+ );
+
+ const className =
+ document.querySelector('[data-slot="dialog-content"]')?.getAttribute('class') ?? '';
+ expectVisualClassTokens(className, ['max-h-[20rem]']);
+ expectVisualClassTokensAbsent(className, ['max-h-[calc(100dvh-6rem)]']);
+ });
+});
diff --git a/packages/app/src/components/ui/dialog.tsx b/packages/app/src/components/ui/dialog.tsx
index dffe2f8f9..6b51e15cd 100644
--- a/packages/app/src/components/ui/dialog.tsx
+++ b/packages/app/src/components/ui/dialog.tsx
@@ -3,6 +3,7 @@ import { XIcon } from 'lucide-react';
import { Dialog as DialogPrimitive } from 'radix-ui';
import type * as React from 'react';
import { Button } from '@/components/ui/button';
+import { ElectronDragStrip, electronDragBandClearance } from '@/components/ui/electron-drag-strip';
import { ignoreToastInteractOutside } from '@/components/ui/toast-outside-guard';
import { cn } from '@/lib/utils';
@@ -37,7 +38,9 @@ function DialogOverlay({
// visually overlaps those drag strips fall through to the OS window-
// drag handler — outside-click dismissal silently breaks for dialogs
// anchored near the top of the window in the Electron frame. Property
- // is a no-op outside Chromium-in-Electron.
+ // is a no-op outside Chromium-in-Electron. The blanket also covers the
+ // chrome rows' own drag regions, which is why DialogContent paints an
+ // ElectronDragStrip back over the title-bar band.
className={cn(
'fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs [-webkit-app-region:no-drag] data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0',
className,
@@ -59,6 +62,8 @@ function DialogContent({
return (
<DialogPortal>
<DialogOverlay />
+ {/* Between overlay and content, deliberately — see ElectronDragStrip. */}
+ <ElectronDragStrip testId="dialog-drag-strip" />
<DialogPrimitive.Content
data-slot="dialog-content"
// Dismissing a sonner toast must not close the dialog beneath it —
@@ -68,7 +73,9 @@ function DialogContent({
// + footer composition; consumers may override via `className`
// (cn() last-wins — SettingsDialogShell switches to a grid, CommandDialog
// drops the padding entirely). max-h caps height to viewport (mirrors
- // the horizontal max-w-[calc(100%-2rem)] with a symmetric 2rem buffer).
+ // the horizontal max-w-[calc(100%-2rem)] with a symmetric 2rem buffer);
+ // on the desktop host electronDragBandClearance() widens that buffer to
+ // clear the title-bar drag band.
// overflow-hidden on the dialog itself; scrolling lives inside
// DialogBody (flex-1 + min-h-0 + overflow-y-auto), so the footer
// stays pinned and the scrollbar never crosses the footer's border-t
@@ -84,6 +91,7 @@ function DialogContent({
// Chromium-in-Electron.
className={cn(
'fixed top-1/2 left-1/2 z-50 flex w-full max-w-[calc(100%-2rem)] max-h-[calc(100dvh-2rem)] -translate-x-1/2 -translate-y-1/2 flex-col gap-6 overflow-hidden rounded-xl bg-popover p-6 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm [-webkit-app-region:no-drag] data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:data-open:animate-none motion-reduce:data-closed:animate-none motion-reduce:duration-0',
+ electronDragBandClearance(),
className,
)}
{...props}
diff --git a/packages/app/src/components/ui/electron-drag-strip.tsx b/packages/app/src/components/ui/electron-drag-strip.tsx
new file mode 100644
index 000000000..ee28f5712
--- /dev/null
+++ b/packages/app/src/components/ui/electron-drag-strip.tsx
@@ -0,0 +1,90 @@
+/**
+ * 48px of restored title-bar reach — one chosen value, not a measurement.
+ *
+ * The two window classes disagree, so no single number is exact. The editor
+ * window's chrome spans y=0..56 (an 8px vibrancy strip above the rows, see
+ * `App.tsx`), leaving y=48..56 unrestored. The Navigator's chrome row is `h-9`,
+ * so the band reaches 12px past it and turns that much overlay into drag
+ * region. Both slips are accepted: the band only has to be a target big enough
+ * to grab, and over- or under-shooting by a few pixels costs a sliver of
+ * dismissal area or of reach, not correctness.
+ *
+ * `DRAG_BAND_CLEARANCE` below is hand-derived from this value. Changing one
+ * means changing the other; nothing type-checks the pair.
+ */
+const DRAG_BAND_HEIGHT = 'h-12';
+
+/**
+ * Caps a vertically centered dialog so it can never grow under the drag band.
+ *
+ * Twice the band height, because the dialog is centered: a symmetric cap is
+ * what buys the top gap without abandoning `top-1/2 -translate-y-1/2`. A dialog
+ * tall enough to care gives up height rather than sliding under the band.
+ */
+const DRAG_BAND_CLEARANCE = 'max-h-[calc(100dvh-6rem)]';
+
+function isElectronHost() {
+ return typeof window !== 'undefined' && window.okDesktop != null;
+}
+
+/**
+ * The max-height a modal surface must respect to stay clear of the drag band,
+ * or `undefined` off the desktop host — a browser tab has no band to clear.
+ *
+ * Belongs in the same `cn()` call as the surface's own `max-h`, ahead of any
+ * caller `className`, so tailwind-merge drops the unclamped value while a
+ * caller override still wins.
+ */
+export function electronDragBandClearance(): string | undefined {
+ return isElectronHost() ? DRAG_BAND_CLEARANCE : undefined;
+}
+
+/**
+ * Hands the title-bar band back to the window while a modal overlay is open.
+ *
+ * A modal overlay blankets the viewport with `-webkit-app-region: no-drag`,
+ * which also neutralizes the chrome-row drag regions underneath it — so an open
+ * dialog leaves an Electron window immovable until it is answered. Painting a
+ * `drag` strip over that band restores it.
+ *
+ * MUST render between the overlay and the content. Chromium folds app regions
+ * in DOM order — a layout-tree walk collecting each region, then a sequential
+ * union/difference over that list, with z-index and paint order never consulted
+ * — so that one position is what lets the strip beat the overlay while still
+ * losing to the dialog itself. Moved above the content, it would turn the
+ * top of a viewport-tall dialog — its heading, its close affordance — into drag
+ * region and swallow those clicks, the exact failure `no-drag` on the content
+ * exists to prevent. `electronDragBandClearance` keeps the two from overlapping
+ * at all; the ordering is the backstop for whatever a caller `className` pushes
+ * back under the band.
+ *
+ * `pointer-events-none` keeps the strip out of DOM hit-testing while
+ * `-webkit-app-region` still resolves at the compositor — the same pairing the
+ * editor-window chrome strip in `App.tsx` uses. `data-electron-drag` opts it
+ * into the `globals.css` rule that suspends drag while a popper floater is open,
+ * so a menu opened from inside the dialog stays dismissable by clicking the
+ * band. That rule matches an explicit slot list rather than all floaters, so a
+ * new popper primitive that can open inside a dialog has to be added there or
+ * its outside-click dismissal dies on these pixels.
+ *
+ * The band costs the pixels it covers their outside-click dismissal: the OS
+ * claims pointer events over a drag region before the DOM sees them, so a
+ * dialog that dismisses on outside click no longer does so along its top edge.
+ * Escape, the close button, and the rest of the overlay are unaffected — a
+ * window that cannot be moved is the worse of the two.
+ *
+ * `testId` is per-surface rather than baked in because a Dialog can host an
+ * AlertDialog, putting two strips in the tree at once.
+ */
+export function ElectronDragStrip({ testId }: { testId: string }) {
+ if (!isElectronHost()) return null;
+
+ return (
+ <div
+ aria-hidden="true"
+ data-testid={testId}
+ data-electron-drag=""
+ className={`pointer-events-none fixed inset-x-0 top-0 z-50 ${DRAG_BAND_HEIGHT} [-webkit-app-region:drag]`}
+ />
+ );
+}
diff --git a/packages/app/src/components/ui/select.dom.test.tsx b/packages/app/src/components/ui/select.dom.test.tsx
index 67aae96cb..e47d03be3 100644
--- a/packages/app/src/components/ui/select.dom.test.tsx
+++ b/packages/app/src/components/ui/select.dom.test.tsx
@@ -107,6 +107,20 @@ describe('Select runtime class contracts', () => {
expectVisualClassTokens(className, POPPER_COLLISION_OFFSETS);
});
+ test('open content matches the globals.css drag-suspension selector', async () => {
+ // `globals.css` suspends the Electron drag band while a floater is open by
+ // matching `[data-slot="select-content"][data-state="open"]`. A Select can
+ // open inside a Dialog, whose overlay no longer covers the band, so if
+ // either attribute stops being emitted the selector goes silently inert and
+ // clicking the band drags the window instead of closing the Select. jsdom
+ // cannot evaluate `:has()`, but it can pin the attributes it keys off.
+ await renderSelectContent();
+
+ const content = document.querySelector('[data-slot="select-content"]');
+ expect(content).toBeTruthy();
+ expect(content?.getAttribute('data-state')).toBe('open');
+ });
+
test('snappy transition tier and long-form state drift do not return', async () => {
await renderSelectContent();
diff --git a/packages/app/src/globals.css b/packages/app/src/globals.css
index 61f824e14..11f5b6056 100644
--- a/packages/app/src/globals.css
+++ b/packages/app/src/globals.css
@@ -5911,13 +5911,27 @@ html.electron-mode [data-slot="sidebar-inner"] {
macOS hijacks pointer events in drag regions at the OS chrome level — the
DOM never sees the `pointerdown`, so Radix's document-level outside-click
- listener cannot fire. Dialogs are already exempt because `DialogOverlay`
- renders with `[-webkit-app-region:no-drag]` covering the viewport; Popper-
- based components do not render an overlay and would otherwise be
- undismissable by clicking the chrome rows (EditorHeader, EditorTabs,
- FileSidebar header, the wrapper-strip in `App.tsx`, NavigatorApp's chrome
- row). Each drag-region site carries a stable `data-electron-drag`
- attribute that this selector targets. Tooltip / HoverCard are excluded
+ listener cannot fire. Popper-based components render no overlay and would
+ otherwise be undismissable by clicking the chrome rows (EditorHeader,
+ EditorTabs, FileSidebar header, the wrapper-strip in `App.tsx`,
+ NavigatorApp's chrome row). Each drag-region site carries a stable
+ `data-electron-drag` attribute that this selector targets.
+
+ Dialogs used to be exempt: `DialogOverlay`'s viewport-wide
+ `[-webkit-app-region:no-drag]` suppressed every drag region beneath it. They
+ are not any more — `ElectronDragStrip` paints a `drag` band back over the
+ title bar so the window stays movable while a dialog is open, and that band
+ carries `data-electron-drag` to opt into this rule. So the list has to cover
+ floaters that open INSIDE a dialog, not just those that open from the
+ chrome. `select-content` is here for that reason: Settings renders `Select`
+ controls in its Attachments and Content-rules sections and for the language
+ field under Preferences, all inside the Settings `Dialog`.
+
+ The `menubar-*` entries are unrelated to dialogs. `AppMenubar` renders only
+ into the two chrome rows (`EditorHeader`, `NavigatorApp`), so a menubar
+ opened from a chrome row could never be dismissed by clicking that same
+ row — a gap that predates the dialog work and is fixed here because the
+ audit that found the `Select` case surfaced it. Tooltip / HoverCard are excluded
intentionally — they dismiss on `pointerleave`, not pointerdown, and
keeping drag live during a hover preserves the window-drag affordance.
@@ -5930,7 +5944,10 @@ html.electron-mode [data-slot="sidebar-inner"] {
[data-slot="dropdown-menu-content"][data-state="open"],
[data-slot="dropdown-menu-sub-content"][data-state="open"],
[data-slot="context-menu-content"][data-state="open"],
- [data-slot="context-menu-sub-content"][data-state="open"]
+ [data-slot="context-menu-sub-content"][data-state="open"],
+ [data-slot="select-content"][data-state="open"],
+ [data-slot="menubar-content"][data-state="open"],
+ [data-slot="menubar-sub-content"][data-state="open"]
)
[data-electron-drag] {
-webkit-app-region: no-drag;
diff --git a/packages/app/src/globals.test.ts b/packages/app/src/globals.test.ts
index 5b4af0582..868fb7f81 100644
--- a/packages/app/src/globals.test.ts
+++ b/packages/app/src/globals.test.ts
@@ -35,7 +35,7 @@ describe('globals.css drag-region neutralization (Popper outside-click in Electr
});
test('the rule fires for every Popper-based slot that needs outside-click dismissal', () => {
- // The three Popper-based primitives are the bug's surface area. Tooltips
+ // Tooltips
// and HoverCards are intentionally excluded — they dismiss on
// pointerleave (not pointerdown), and keeping drag live during hover
// preserves the window-drag affordance.
@@ -45,6 +45,14 @@ describe('globals.css drag-region neutralization (Popper outside-click in Electr
'dropdown-menu-sub-content',
'context-menu-content',
'context-menu-sub-content',
+ // Opens inside a Dialog, whose overlay no longer suppresses the drag
+ // band beneath it — see ElectronDragStrip.
+ 'select-content',
+ // Chrome-row only (AppMenubar renders into EditorHeader / NavigatorApp,
+ // never into a dialog): without these, a menubar opened from a chrome
+ // row cannot be dismissed by clicking that same row.
+ 'menubar-content',
+ 'menubar-sub-content',
];
for (const slot of requiredSlots) {
expect(src).toContain(`[data-slot="${slot}"][data-state="open"]`);