Events inside a portal don't bubble to the portal's React parents
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 38/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript, react
- 領域
- frontend
調査の方向性
Start with createPortal in the Redact implementation and the event wrapping in synthetic-event.js; compare how handlers are attached and how propagation across the React tree is represented. Reproduce with the issue's one-parent, one-portal StackBlitz case, then verify portal clicks reach the parent and the Radix popover/dialog case behaves like React DOM. Also check SURFACE.md and the compatibility documentation for the documented portal guarantees.
索引モデルが issue の本文から書いたものです。
説明
In React DOM, an event fired inside a portal bubbles through the React tree, so the component that renders the portal receives it. In Redact the event bubbles only through the DOM tree, so no React parent of the portal sees it.
Reproduction
Both links open the same StackBlitz project, so you install nothing. They differ only in the start script:
- Run it on Redact. Both cases fail.
- Run it on React DOM. Both cases pass.
| Redact | React DOM |
|---|---|
The smallest case is one parent with one portal:
import { useState } from 'react'
import { createPortal } from 'react-dom'
function App() {
const [clicks, setClicks] = useState(0)
return (
<div onClick={() => setClicks((n) => n + 1)}>
<p>Parent saw {clicks} clicks</p>
{createPortal(<button>Inside portal</button>, document.body)}
</div>
)
}
Expected. Each click on Inside portal reaches the parent, as it does in React DOM.
Actual. In Redact the parent sees 0 clicks.
I get the same result in Chromium and WebKit, with real Playwright clicks on production builds and by hand on the StackBlitz links.
Impact on headless UI libraries
Libraries decide whether a click lands inside or outside a layer through events that cross the portal. Without React-tree bubbling, a layer nested in a portal counts its own clicks as outside:
- Radix. Clicking an item of a
Popoverinside aDialogcloses theDialog.DismissableLayermarks a pointer press as inside through itsonPointerDownCapture, and the popover content reaches that handler only through the React tree. The StackBlitz project shows this case withradix-ui1.8.1. - Base UI. #70 looks like the same cause. A submenu in a portal closes on
outside-pressbefore its link gets the click.
Cause
In 0.2.3, createPortal only returns the element, and synthetic-event.js wraps the native event. Each handler listens on its own element, so the event follows the DOM tree. The compatibility docs list portals as supported, and SURFACE.md marks createPortal as basic. Neither page mentions that portal events follow the DOM tree.
Do you want Redact to match React here? If you do, I can send a PR once you pick the approach. If you don't, a line in the compatibility docs that says portal events follow the DOM tree would tell users what to expect.
Versions. Redact 0.2.3, radix-ui 1.8.1, React 19.2.0, Vite 8.3.5, @vitejs/plugin-react 6.1.2, Chromium 156.0.8078.4, and WebKit 27.2 from Playwright.
- 主要言語
- TypeScript
- スター
- 537
- フォーク
- 22
- 平均マージ
- 11時間 28分
- マージ済み PR(30日)
- 34
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/redact のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
TanStack/redact#142 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
TanStack/redact#144 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
TanStack/redact#141 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
TanStack/redact の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
bug needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
DSpace/dspace-angular#6511 ·
メンテナーはふだん 1 日以内に返信
-
area: frontend area:byok bug severity:low
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
Phone app shows Unknown for a remote machine whose key changed対応中かも @janicduplessis が今日担当しました。 オープンarea: mobile priority: P3 type: bug
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
appandflow/stim#5006 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Area - Local to Cloud Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
microsoft/vscode-mssql#23209 ·
メンテナーはふだん 1 日以内に返信