Observe: open one interaction frame per event, so listeners outside the runtime can join it
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 36.1k
- Fork
- 1.1k
- Merge trung bình
- 11 giờ 25 phút
- Pull request đã merge (30 ngày)
- 345
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của solidjs/solid
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 12/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Select loses its bound value when options load asynchronouslyCó thể đã có người làm @MokiMeow đã nhận hôm nay. Đang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 45/100
solidjs/solid#3928 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 24/100
solidjs/solid#3923 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solidjs/solid
Issue tương tự
-
[Bug]: Server git tests sign fixture commits with the developer's key when run from the repo rootĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
melgarafael/DeskcommCRM#2657 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
MystenLabs/MemWal#1163 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
"Explore the letters"-button should read "Explore the papers"Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởMondriaan
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
knaw-huc/textannoviz#709 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
billion-context-pi
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
ranxianglei/billion-context#2521 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày