Repository navigation
Description
Observed behavior
A Dialog counts as nested whenever another Dialog (or Drawer) is above it in the component tree, even when that dialog is closed and the second one is not drawn inside its popup. The second dialog gets data-nested, and its backdrop returns undefined, so an open modal dialog shows no backdrop.
The documentation describes nesting for a dialog "drawn inside another one's popup". In Dialog.ts the check is p.reads.parent !== undefined && props.nested !== false, so any dialog component higher up in the tree is treated as a parent, whether it is open or not.
I ran into this with an app shell. CreaseUI's Sidebar uses a Drawer for the mobile navigation, and its view draws the whole shell, including the page content beside the drawer's popup. On desktop the drawer is closed and its popup is not drawn, yet every edit dialog on every page is marked nested and opens without a backdrop.
Expected behavior
A dialog beside a closed dialog's popup should behave like a top-level dialog: no data-nested, and a backdrop. Nesting should apply only to a dialog drawn inside the other dialog's popup, or at least only while that dialog is open.
Reproduction
Verified with Node 26.4.0 and Effect 4.1.7 on snapshot 29833dc. In an empty directory, save the snippet below as repro.mjs and run:
npm init -y
npm install https://pkg.pr.new/Effect-TS/effect/effect@29833dc
node repro.mjs
node repro.mjs --top-levelThe first run prints Beside a closed dialog: data-nested=true, backdrop=false and fails the assertion. With --top-level, the same dialog without the closed dialog around it prints Top level: data-nested=false, backdrop=true.
repro.mjs
import assert from 'node:assert/strict'
import { Html, HtmlServer } from 'effect/ui/html'
import { Dialog } from 'effect/ui/kit'
import { Effect, Schema } from 'effect'
const topLevel = process.argv.includes('--top-level')
const ignore = {
RequestedOpen: () => undefined,
RequestedClose: () => undefined,
Settled: () => undefined,
}
const Page = Html.component({
name: 'Page',
model: Schema.Null,
message: Schema.Never,
}).make({
init: () => null,
update: $ => $.model,
view: h => {
const edit = Dialog(h, {
key: 'edit',
props: { open: true },
onEmit: ignore,
view: dialog =>
dialog
.portal(h.div)
?.children(
dialog.backdrop(h.div.attr('data-repro', 'backdrop')),
dialog
.viewport(h.div.attr('data-repro', 'viewport'))
.children(dialog.popup(h.div).children(dialog.title(h.h2).children('Edit'))),
),
})
if (topLevel) return h.main(edit)
// A closed dialog whose view also draws the page, as an app shell does for
// its mobile navigation. The edit dialog is beside its popup, not inside it.
return Dialog(h, {
key: 'navigation',
props: { open: false },
onEmit: ignore,
view: navigation =>
h.div(
navigation.trigger(h.button).children('Menu'),
navigation.portal(h.div)?.children(navigation.popup(h.div).children('Navigation')),
h.main(edit),
),
})
},
})
const { html } = await Effect.runPromise(HtmlServer.renderToHtml(Page, {}))
const viewport = /<div[^>]*data-repro="viewport"[^>]*>/.exec(html)?.[0] ?? ''
const nested = /\sdata-nested(?:=""|\s|>)/.test(viewport)
const backdrop = html.includes('data-repro="backdrop"')
console.log(`${topLevel ? 'Top level' : 'Beside a closed dialog'}: data-nested=${nested}, backdrop=${backdrop}`)
assert.equal(nested, false, 'the edit dialog is marked as nested')
assert.equal(backdrop, true, 'the edit dialog has no backdrop')Proposed change
Treat a dialog as nested only when it is drawn inside the parent dialog's popup, as the documentation says. A smaller change would be to ignore a parent that is closed, so a closed navigation drawer no longer affects the dialogs of the page it wraps.
Passing nested: false to every dialog avoids the symptom. That has to be done for each dialog in the app, though, and it also turns off nesting for a dialog that really is opened from inside the drawer.
Activity
clean99 commentedon Dec 2, 2026
For #11328, I would settle the nesting boundary before changing the parent lookup. The parent already shares its
openvalue, but the nesting check only tests whether that parent exists.Two scopes are possible, without adding a public prop:
I would preserve the meanings of
nested: falseandforceRenderBackdropand avoid a second source of nesting state.After agreement, I would add pure-logic tests for the chosen boundary, parent open/close transitions,
keepMounted, and explicit overrides, then rerun the existing Dialog and Drawer tests for counts and dismissal.Would you prefer the closed-parent fix first, or popup-scoped nesting that matches the documented boundary?