Observe: open one interaction frame per event, so listeners outside the runtime can join it
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- typescript
調査の方向性
Start with the existing internal dispatchAsInteraction implementation and the observe export surface in @solidjs/web; no specific files or tests are named. Compare the proposed per-event frame lifetime and public export against native and synthetic dispatch behavior, and consider the listed re-dispatch, timing, and preload-listener questions; done means one interaction record per event with outside listeners able to join.
索引モデルが issue の本文から書いたものです。
説明
Observed with solid-js / @solidjs/web 2.0.0-rc.13 (observe build) and @solidjs/router next. Context: solidjs/solid-router#643.
Problem
An interaction frame is opened per listener, not per event. dispatchAsInteraction wraps each runtime-attached handler in its own withInteraction call, and the frame is recorded (as "idle" if nothing was written) as soon as that handler returns.
That leaves code outside the runtime with no good option when it reacts to the same event:
- If it uses plain
addEventListener, its work runs outside any frame. Today, router navigations from anchor clicks and form submits getNavigationEvent.interaction === undefined. This is solidjs/solid-router#643. - If it opens its own frame (through
addEvent(…, false)orwithInteraction), the click produces two records. The render root's delegated listener has already opened and closed a frame for that click, recorded as idle. The second record carries the navigation.
What I saw clicking one <a> inside a rendered root:
| Router listener | Interaction records | NavigationEvent.interaction |
|---|---|---|
plain addEventListener (today) |
1: click a#go, idle |
undefined |
through addEvent(document, "click", h, false) |
2: the same idle record, then a second click a#go that owns the navigation |
the second record |
If the anchor also has an onClick that does work, that work lands on the first record and the navigation on the second. One user click shows up as two interactions, which skews INP-style numbers and the click spans that consumers display.
Attaching per root container instead of on document doesn't help, because it is still a second listener and a second frame. Neither does looking up the anchor's container first: frames aren't tied to containers, and by the time the event bubbles to a later listener, the delegated frame has already closed.
Proposal: one frame per event
- Runtime:
dispatchAsInteraction(e, fn)remembers the frame it opened fore, for example in aWeakMap<Event, Frame>. A later call for the same event re-enters that frame instead of opening a new one. - Engine: the frame is finalized (recorded, or marked idle) after the event's dispatch, not when the first handler returns. All listeners for one dispatch run within a single task, so closing at the next task works for both native and synthetic events. A microtask is too early: browsers run microtasks between listeners for native events.
- Surface: export
dispatchAsInteractionfrom@solidjs/web. It already exists internally and is the only new public entry point. Like every other observe hook, it folds out of production builds.
The router would then just wrap its click and submit bodies, dispatchAsInteraction(e, () => …), and keep listening on document. That gives one record per click, with both the onClick work and the navigation in it, and NavigationEvent.interaction set.
Why this belongs in core, not the router
Only the runtime knows that a frame already exists for an event. Any library that listens at the document level hits this: routers, analytics, drag-and-drop, focus/a11y helpers. The router could call OBSERVE.attribution.withInteraction itself, but that opens the duplicate frame above and copies the runtime's target-description and privacy logic.
That said, a public API that mainly serves this case is a fair concern. The alternative I'd weigh is the delegated-handler route: a frame-aware way for a second handler to join the delegated dispatch on an element. The delegated slot ($$click) is single-handler today, and the author's onClick already fills it. That fixes compiler-claimed anchors but not elements outside a root or unclaimed anchors, which is why I lean towards the per-event frame.
Open questions
- A listener running after its event's frame has closed (for example a re-dispatched event): should it open a fresh frame? I'd say yes.
- Records arrive one task later. Timing still comes from
e.timeStamp, so measurements don't change. Is the delay acceptable for consumers? - Should the preload-style listeners (
mousemove,focusin) stay outside frames? For the router, yes: wrapping them would flood the records with idle interactions. That's a usage guideline, not something the runtime needs to enforce.
- 主要言語
- TypeScript
- スター
- 36.1k
- フォーク
- 1.1k
- 平均マージ
- 10時間 7分
- マージ済み PR(30日)
- 289
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
solidjs/solid のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
platformatic/mcp#208 ·
メンテナーはふだん 1 日以内に返信
-
🐛 bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
margelo/react-native-vision-camera#4211 ·
メンテナーはふだん 4 日以内に返信