Radix Dialog closes on portaled Popover selection in 0.3.0: parent pointer capture is missing
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- playwright, react, typescript, vite
Direzione di ricerca
Start with packages/redact/src/dom/dom.ts and packages/redact/src/dom/features/portal/full.ts, which the report identifies as the event-listener and portal-rendering paths. Use the four-file reproduction and compare the Redact and React production builds with real pointer clicks. Done means logical capture propagation reaches the Dialog before the Popover and selecting an item keeps the Dialog open while legitimate outside dismissal still works.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happens
With Redact 0.3.0 and its Vite plugin, selecting a plain button inside a Radix Popover dismisses the parent Dialog. React 19.3.1 closes only the Popover and leaves the Dialog open with the selected value.
A plain createPortal probe also shows that the logical parent's onPointerDownCapture never runs. This reproduces without cmdk, SSR, hydration, React Compiler, a router, or application code.
Related to #119, which already describes missing React-tree propagation across portals. This is a fresh four-file reproduction on the current stable release with the capture-phase trace for the Dialog dismissal. It may be the same underlying issue. The format follows the earlier resolved event-contract report #57; this is a different contract failure.
Minimal reproduction
Create these four files in an empty directory. All direct dependency versions are pinned.
package.json
{
"name": "redact-dialog-portal-repro",
"private": true,
"type": "module",
"scripts": {
"build": "vite build",
"preview": "vite preview --host 127.0.0.1"
},
"dependencies": {
"@tanstack/redact": "0.3.0",
"radix-ui": "1.8.1",
"react": "19.3.1",
"react-dom": "19.3.1"
},
"devDependencies": {
"vite": "8.3.5"
}
}
index.html
<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Dialog portal event reproduction</title></head>
<body><div id="root"></div><script type="module" src="/main.js"></script></body>
</html>
vite.config.js
import { defineConfig } from 'vite'
import { redact } from '@tanstack/redact/vite'
export default defineConfig({
plugins: process.env.RUNTIME === 'react' ? [] : [redact()],
})
main.js
import { createElement as h, useState } from 'react'
import { createPortal } from 'react-dom'
import { createRoot } from 'react-dom/client'
import { Dialog, Popover } from 'radix-ui'
window.portalTrace = []
const record = (name) => window.portalTrace.push(name)
function App() {
const [captures, setCaptures] = useState(0)
const [open, setOpen] = useState(false)
const [value, setValue] = useState('Choose item')
return h('main', null,
h('div', {
onPointerDownCapture() { setCaptures((n) => n + 1) },
},
h('output', { id: 'captures' }, `Parent captures: ${captures}`),
createPortal(h('button', { type: 'button' }, 'Plain portal probe'), document.body),
),
h(Dialog.Root, {
onOpenChange(value) { record(`dialog open: ${value}`) },
},
h(Dialog.Trigger, null, 'Open dialog'),
h(Dialog.Portal, null,
h(Dialog.Overlay),
h(Dialog.Content, {
onPointerDownCapture() { record('dialog capture') },
onPointerDownOutside() { record('dialog outside') },
},
h(Dialog.Title, null, 'Example dialog'),
h(Dialog.Description, null, 'Selecting an item should keep this dialog open.'),
h(Popover.Root, { open, onOpenChange: setOpen },
h(Popover.Trigger, { id: 'selection' }, value),
h(Popover.Portal, null,
h(Popover.Content, {
onPointerDownCapture() { record('popover capture') },
},
h('button', {
type: 'button',
onClick() {
record('select')
setValue('Example')
setOpen(false)
},
}, 'Select Example'),
),
),
),
h(Dialog.Close, null, 'Close dialog'),
),
),
),
)
}
createRoot(document.getElementById('root')).render(h(App))
Run the Redact production build:
npm install
npm run build
npm run preview -- --port 4173
Open http://127.0.0.1:4173:
- Click Plain portal probe. The output stays
Parent captures: 0. - Click Open dialog, then Choose item.
- In the browser console, clear
window.portalTrace = []. - Click Select Example. The entire Dialog disappears. Inspect
window.portalTrace.
For the React control, stop the preview, rebuild and reload:
RUNTIME=react npm run build
RUNTIME=react npm run preview -- --port 4173
Repeat the steps. The probe reports Parent captures: 1. Selection changes the trigger to Example, closes the Popover and keeps the Dialog open.
Verified result
I ran both production builds independently using real Playwright pointer clicks on Linux with Bun 1.4.4, Playwright 1.64.1 and Chromium 151.0.7922.173. Dependencies were installed in a fresh directory. The Redact build's module graph contained Redact and no upstream React/React DOM runtime. The automated check produced:
{"runtime":"react","plainCapture":"Parent captures: 1","trace":["dialog capture","popover capture","select"],"dialogs":1,"selection":"Example","errors":[]}
{"runtime":"redact","plainCapture":"Parent captures: 0","trace":["popover capture","select","dialog outside","dialog open: false"],"dialogs":0,"selection":null,"errors":[]}
The same results were observed on Redact 0.2.6. Redact 0.3.0 was checked after its publication on November 3, 2026, so this report does not assume the earlier reproduction still applies.
Expected behavior and observed cause
React's portal contract preserves event propagation through the React tree. In this case the Dialog's capture handler must run before the nested Popover's capture handler, even though their DOM nodes are siblings under document.body.
In Redact 0.3.0, setEventHandler installs a native listener directly on each element. The portal renderer reconciles the children but does not bridge the logical ancestor event path.
The installed @radix-ui/react-dismissable-layer 1.2.1 marks pointer presses as internal in onPointerDownCapture. Because the Dialog's capture never runs for the Popover's content, its document listener classifies the press as external. With Radix's deferred outside handling, the trace shows selection first, then dismissableLayer.pointerDownOutside, then onOpenChange(false).
As a diagnostic, giving the Popover a portal container inside the Dialog restores the capture and prevents dismissal in both runtimes. That is not a general application fix: a centered, transformed Dialog with internal scrolling clips the Popover and changes its positioning. The reproduction above keeps the normal body portal and does not prevent outside events or patch either library.
Supporting capture and bubble propagation through logical portal ancestry would preserve Radix's normal inside/outside behavior without disabling legitimate outside dismissal or requiring application event shims.
- Lingua principale
- TypeScript
- Stelle
- 640
- Fork
- 32
- Merge medio
- 1h 15m
- PR unite (30g)
- 7
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/redact
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
TanStack/redact#195 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TanStack/redact#142 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/redact
Issue simili
-
bug data-types
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
ClickHouse/clickhouse-js#1293 ·
I maintainer di solito rispondono entro 1 giorno
-
area: middleware enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
agent/quality testing
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
I maintainer di solito rispondono entro 1 giorno
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
juspay/agent-distro#203 ·
I maintainer di solito rispondono entro 1 giorno