fix(desktop): stop dialogs clipping popovers opened inside them

DialogContent published itself as the portal container for popovers opened
inside a dialog (so focus stays in the dialog and dismissal doesn't close it),
but that same element carried `overflow-y-auto`. Every Select/Popover/
DropdownMenu in a dialog was therefore born inside a scroll box and got
cropped at the dialog's edge — most visibly the worktree dialog's base-branch
combobox, where the branch list was cut off entirely and only the search field
showed.

Split the box in two: the shell keeps position/size/skin and no longer clips
(it stays the portal container), while a new inner body div owns layout and
scrolling. Popovers remain DOM descendants of the dialog, so focus and
dismissal behave exactly as before, but they can now paint past the dialog's
bounds. The banner variant had the same `overflow-hidden` on its shell; its
clip moves to the banner itself, which keeps the rounded bottom edge.

Callers that passed layout/scroll classes (grid, gap-*, p-*, overflow-*) now
pass them via the new `bodyClassName`; `className` keeps sizing and skin.
This commit is contained in:
ethernet
2026-07-31 15:15:36 -04:00
parent ee7c614eef
commit b846f0c002
12 changed files with 41 additions and 19 deletions
@@ -127,7 +127,7 @@ function PromptSnippetsDialog({ onInsertText, onOpenChange, open }: PromptSnippe
return (
<Dialog onOpenChange={onOpenChange} open={open}>
<DialogContent className="max-w-md gap-3">
<DialogContent className="max-w-md">
<DialogHeader>
<DialogTitle>{c.snippetsTitle}</DialogTitle>
<DialogDescription>{c.snippetsDesc}</DialogDescription>
@@ -37,7 +37,7 @@ export function UrlDialog({
return (
<Dialog onOpenChange={onOpenChange} open={open}>
<DialogContent className="max-w-md gap-5">
<DialogContent bodyClassName="gap-5" className="max-w-md">
<DialogHeader>
<DialogTitle icon={Globe}>{c.attachUrlTitle}</DialogTitle>
<DialogDescription>{c.attachUrlDesc}</DialogDescription>
@@ -81,9 +81,10 @@ export function PetGenerateOverlay() {
aria-describedby={undefined}
banner={banner}
bannerTone={errored ? 'error' : 'info'}
bodyClassName="gap-4 text-center"
// Cap the width so a long banner (e.g. a provider refusal) wraps instead
// of stretching the dialog out; the min-w floors each phase.
className={cn('gap-4 text-center', single ? 'min-w-[17rem] max-w-[20rem]' : 'min-w-[19rem] max-w-[22rem]')}
className={cn(single ? 'min-w-[17rem] max-w-[20rem]' : 'min-w-[19rem] max-w-[22rem]')}
fitContent
>
{open && <PetGenerateContent />}
@@ -121,7 +121,7 @@ export function RemoteFolderPicker() {
return (
<Dialog onOpenChange={open => !open && close()} open={Boolean(pending)}>
<DialogContent className="flex h-[min(36rem,calc(100vh-4rem))] max-w-lg flex-col gap-0 overflow-hidden p-0">
<DialogContent bodyClassName="flex min-h-0 flex-col gap-0 overflow-hidden p-0" className="h-[min(36rem,calc(100vh-4rem))] max-w-lg">
<div className="shrink-0 border-b border-border/70 px-4 py-3">
<DialogTitle className="text-sm">{pending?.title || r.remotePickerTitle}</DialogTitle>
<DialogDescription className="mt-1 text-xs">{r.remotePickerDescription}</DialogDescription>
@@ -91,7 +91,7 @@ export function ProviderConfigModal({
return (
<Dialog onOpenChange={onOpenChange} open={open}>
<DialogContent className="max-w-2xl dt-portal-scrollbar">
<DialogContent bodyClassName="dt-portal-scrollbar" className="max-w-2xl">
<DialogHeader>
<DialogTitle icon={SlidersHorizontal}>{config.label} — full configuration</DialogTitle>
<DialogDescription>
+1 -1
View File
@@ -391,7 +391,7 @@ export function SkillsHub({ query }: SkillsHubProps) {
)}
<Dialog onOpenChange={open => !open && setDetail(null)} open={detail !== null}>
<DialogContent className="max-h-[80vh] max-w-2xl overflow-hidden">
<DialogContent bodyClassName="overflow-hidden" className="max-h-[80vh] max-w-2xl">
{detail && (
<>
<DialogHeader>
+1 -1
View File
@@ -104,7 +104,7 @@ export function UpdatesOverlay() {
{/* This dialog has no inputs, so Radix's default autofocus would land on
the close button and trigger its tooltip immediately on open. */}
<DialogContent
className="max-w-sm overflow-hidden p-0 gap-0"
bodyClassName="overflow-hidden p-0 gap-0" className="max-w-sm"
onOpenAutoFocus={preventCloseButtonAutoFocus}
showCloseButton={phase !== 'applying'}
>
@@ -79,7 +79,7 @@ export function ImageLightbox({
return (
<Dialog onOpenChange={onOpenChange} open={open}>
<DialogContent
className="block w-auto max-h-[calc(100vh-12rem)] max-w-[calc(100vw-12rem)] overflow-visible border-0 bg-transparent p-0 shadow-none"
bodyClassName="block overflow-visible p-0" className="w-auto max-h-[calc(100vh-12rem)] max-w-[calc(100vw-12rem)] border-0 bg-transparent shadow-none"
showCloseButton={false}
>
<div className="group/lightbox relative inline-block">
+4 -1
View File
@@ -94,7 +94,10 @@ export function ModelPickerDialog({
return (
<Dialog onOpenChange={onOpenChange} open={open}>
<DialogContent className={cn('max-h-[85vh] max-w-2xl gap-0 overflow-hidden p-0', contentClassName)}>
<DialogContent
bodyClassName="gap-0 overflow-hidden p-0"
className={cn('max-h-[85vh] max-w-2xl', contentClassName)}
>
<DialogHeader className="border-b border-border px-4 py-3">
<DialogTitle>{copy.title}</DialogTitle>
<DialogDescription className="font-mono text-xs leading-relaxed">
@@ -78,7 +78,7 @@ export function ModelVisibilityDialog({
return (
<Dialog onOpenChange={onOpenChange} open={open}>
<DialogContent className="max-w-xs gap-0 overflow-hidden p-0">
<DialogContent bodyClassName="gap-0 overflow-hidden p-0" className="max-w-xs">
<DialogHeader className="px-3 pb-1 pt-3">
<DialogTitle className="text-[0.8125rem]">{copy.title}</DialogTitle>
</DialogHeader>
+26 -8
View File
@@ -62,6 +62,7 @@ export function preventCloseButtonAutoFocus(event: Event) {
function DialogContent({
className,
bodyClassName,
children,
showCloseButton = true,
fitContent = false,
@@ -75,6 +76,10 @@ function DialogContent({
// default fixed `max-w-lg`. For content that has no intrinsic width (grids,
// full-width inputs) pair it with a `min-w-*` in `className`.
fitContent?: boolean
// Layout and scroll classes for the inner body box: padding, gap, display,
// overflow. `className` styles the OUTER shell: position, size, border, and
// background. The note on the shell below explains this split.
bodyClassName?: string
// A dialog-level notice rendered as a banner flush to the bottom edge (tinted,
// inherited bottom radius) so it reads as part of the dialog, not a floating
// alert. Falsy → no banner. Tone picks the colour.
@@ -123,7 +128,10 @@ function DialogContent({
<DialogOverlay />
<DialogPrimitive.Content
className={cn(
'fixed left-1/2 top-1/2 z-(--z-modal) pointer-events-auto flex max-h-[85vh] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl bg-(--ui-chat-bubble-background) text-[length:var(--conversation-text-font-size)] text-foreground shadow-nous duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95',
// The same split as the plain variant. The shell must not clip,
// because it crops the popovers that portal into it. The banner
// below has its own `overflow-hidden`, which rounds its corners.
'fixed left-1/2 top-1/2 z-(--z-modal) pointer-events-auto flex max-h-[85vh] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl bg-(--ui-chat-bubble-background) text-[length:var(--conversation-text-font-size)] text-foreground shadow-nous duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95',
widthClass,
className,
// Callers often pass `gap-*` for the no-banner grid layout — suppress
@@ -138,13 +146,15 @@ function DialogContent({
<DialogPortalContainerContext.Provider value={contentNode}>
{/* Scroll lives on an inner box so this shell keeps a painted bottom radius. */}
<div className="relative z-10 overflow-hidden rounded-xl border border-b-0 border-(--stroke-nous) bg-(--ui-chat-bubble-background)">
<div className="grid max-h-[calc(85vh-5rem)] min-h-0 gap-3 overflow-y-auto p-4">{children}</div>
<div className={cn('grid max-h-[calc(85vh-5rem)] min-h-0 gap-3 overflow-y-auto p-4', bodyClassName)}>
{children}
</div>
</div>
<div
className={cn(
// Overlap by one corner radius so the white bottom lobes read clearly
// over the tint instead of meeting it on a straight seam.
'relative z-0 -mt-[var(--radius-xl)] px-4 pb-2.5 pt-[calc(var(--radius-xl)+0.625rem)] text-center text-[length:var(--conversation-tool-font-size)] leading-relaxed shadow-[inset_0_7px_7px_-4px_rgb(0_0_0/0.28)]',
'relative z-0 -mt-[var(--radius-xl)] overflow-hidden rounded-b-xl px-4 pb-2.5 pt-[calc(var(--radius-xl)+0.625rem)] text-center text-[length:var(--conversation-tool-font-size)] leading-relaxed shadow-[inset_0_7px_7px_-4px_rgb(0_0_0/0.28)]',
DIALOG_BANNER_TONES[bannerTone]
)}
data-slot="dialog-banner"
@@ -164,10 +174,13 @@ function DialogContent({
<DialogOverlay />
<DialogPrimitive.Content
className={cn(
// Cap height at 85vh and let long content scroll inside the dialog
// instead of overflowing off-screen (long cron titles, tool detail
// dumps, etc.). Individual dialogs can still override via className.
'fixed left-1/2 top-1/2 z-(--z-modal) pointer-events-auto grid max-h-[85vh] -translate-x-1/2 -translate-y-1/2 gap-3 overflow-y-auto rounded-xl border border-(--stroke-nous) bg-(--ui-chat-bubble-background) p-4 text-[length:var(--conversation-text-font-size)] text-foreground shadow-nous duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95',
// The SHELL: position, size, and skin. It has no overflow of its own,
// and that is deliberate. It is the portal container for the popovers
// that open inside the dialog (see DialogPortalContainerContext), and
// a clipping ancestor crops them. The body box below owns the scroll,
// so a tall dialog scrolls and a Select or Popover can still paint
// past the edge of that box.
'fixed left-1/2 top-1/2 z-(--z-modal) pointer-events-auto flex max-h-[85vh] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-(--stroke-nous) bg-(--ui-chat-bubble-background) text-[length:var(--conversation-text-font-size)] text-foreground shadow-nous duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95',
widthClass,
className
)}
@@ -177,7 +190,12 @@ function DialogContent({
{...props}
>
<DialogPortalContainerContext.Provider value={contentNode}>
{children}
{/* The BODY: layout and scroll. `min-h-0` lets this box shrink inside
the max-height of the shell. The overflow then scrolls here
instead of pushing the shell past the viewport. */}
<div className={cn('grid min-h-0 gap-3 overflow-y-auto rounded-[inherit] p-4', bodyClassName)}>
{children}
</div>
{closeButton}
</DialogPortalContainerContext.Provider>
</DialogPrimitive.Content>
+1 -1
View File
@@ -80,7 +80,7 @@ function ZoomPanViewer({
return (
<Dialog onOpenChange={onOpenChange} open={open}>
<DialogContent
className="flex h-[85vh] w-[90vw] max-w-[90vw] flex-col gap-0 overflow-hidden p-0"
bodyClassName="flex min-h-0 flex-col gap-0 overflow-hidden p-0" className="h-[85vh] w-[90vw] max-w-[90vw]"
showCloseButton={false}
>
<div