A dialog blocks only the region it opened from, and a dialog that shows a resource is a route, not a piece of state.

The problem

The default modal dims and blocks the whole document. That’s fine until the app has two live regions. Someone opens “Delete product?” in the main area, and the assistant beside it locks up too, right when they wanted to ask it whether deleting was a good idea.

The other default is const [open, setOpen] = useState(false) in whatever file opened it. You can’t link to it, Back doesn’t close it, and a shared link to “this order, edit dialog open” lands on the list with no dialog.

What I concluded

Each region of the layout is a modal boundary. Overlays opened inside it portal into it, and while one is open, only that region’s content goes inert: no clicks, no Tab stops, and screen readers skip it. Every other region stays live.

  ┌ main region ───────────────┐ ┌ assistant ─────┐
  │ (inert, dimmed)            │ │ still usable   │
  │     ┌ Delete product? ┐    │ │ Escape here    │
  │     └─────────────────┘    │ │ stays here     │
  └────────────────────────────┘ └────────────────┘

Escape is scoped the same way. An Escape pressed in the assistant belongs to the assistant and doesn’t close the page’s dialog. I leave aria-modal off for these, because it tells assistive tech that everything outside is unavailable, and here it isn’t. A component rendered outside any region falls back to a normal page-wide modal.

Is it a view?

Before reaching for state, I ask whether the dialog is a view. If it shows one resource or creates or edits one, it’s a child route: /items/new, /items/42/edit. The parent renders an outlet, the route component is always open, and reload or share reopens it. A yes/no about an action already in progress stays local state.

Closing pops history when there’s an in-app entry behind it. On a deep link there isn’t one, so it replaces the entry with the parent instead, and Back still leaves the site the way you’d expect. Either way a closed dialog never sits behind you in history. Since the dialog unmounts on navigation, the router’s view transition animates its exit from a snapshot.

Rules

  • Block the region, not the document. Inert goes on the opener’s region. Save document-wide modals for things that really block everything.
  • Escape belongs to where it was pressed. Listen on the region, and mark the event handled so outer layers don’t also close.
  • A scrim click needs the press to start on the scrim. Otherwise selecting text and releasing over the dim closes the dialog.
  • Focus goes back. To the control that opened it, or to the page heading on a deep link.
  • Views get URLs. Showing or editing a resource is a route. Confirms stay state.

What you get

A dialog that blocks what it should and nothing else, so the person can keep using the rest of the app to make the decision. And dialogs that behave like pages: linkable, reloadable, and closed by Back.

The demo shows the region version: toggle it off to see the whole app lock up. Related: Stacked panels, Back button, URL state.