Repository navigation
fix: close the delegated capture window after trusted propagation ends - #929
Merged
Merged
Conversation
The root capture listener queued a microtask to close the capture segment's controlled-restore window when a native listener stops the bubble below the root. Browsers run a microtask checkpoint after every listener of an event they dispatch themselves, so for a trusted event the fallback fired between the root's capture and bubble listeners, restored the controlled value before onInput ran, and lost every keystroke once any onXxxCapture handler for that type was registered anywhere in the app. Trusted events now close the window with a task; script-dispatched events keep the microtask fallback. Also make the controlled-form benchmark report the field state when the typing check times out, and add a real-browser regression comparing Octane and React typing through an onInputCapture ancestor. Co-Authored-By: Claude Fable 5.1 <[email protected]>
trueadm
marked this pull request as ready for review
September 2, 2026 12:15
This was referenced Sep 7, 2026
Closed
3 of 6 tasks
trueadm
added a commit
that referenced
this pull request
Oct 6, 2026
…lers run (#1810) A signal write in a delegated onXxxCapture handler belongs to the native event's signal batch, which the root's bubble walk closes. When a native listener stops propagation below the root, a fallback closes the batch instead. That fallback was a microtask for every event except checkbox and radio change. The browser checkpoints microtasks after every listener of an event it dispatches itself, so for a keystroke, tap or drag the fallback published the capture write between the root's capture and bubble listeners. A component reading the signal re-rendered and reasserted its controlled value before onInput could read the edit: ranges stayed put and typed characters were dropped. #929 already moved the runtime's controlled-restore fallback (finishCaptureDispatch) to a task for trusted events; the batch lease that mirrors it kept the older checkable-change test. Trusted events now close the batch with a task, which also covers the checkable change case, and script-dispatched events keep the microtask. Fixes #1805 Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
node benchmarks/controlled-form/run.mjs octane-tsrx 8timed out onmainat the typing check (input[data-field-index="37"]never reachedoctane benchmaXrk). The weekly bench workflow has shown the same failure on Linux since 2026-08-17 (it passed on 2026-08-10). The React target passes on the same Playwright/Chromium, so keyboard delivery was not the problem: every keystroke into the controlled input was being reverted beforeonInputran.finishCaptureDispatch: when anyonXxxCapturehandler for an event type is registered, the root's capture-phase listener queues a microtask fallback that closes the capture segment's controlled-restore window in case a native listener stops the bubble below the root. Browsers run a microtask checkpoint after every listener of an event they dispatch themselves, so for a trusted event that fallback fired between the root's capture listener and its bubble listener, snapped the controlledvalueback to the last rendered value, andonInputthen read the old value (anObject.is-equal update, so no render). The benchmark fixture'sonInputCapture(added by perf: finish delegated-event and marker optimizations #704) exposed the latent bug.changespecial case was the same bug misdiagnosed as checkbox-specific and is subsumed.Changes
packages/octane/src/runtime.ts:finishCaptureDispatchpicks the fallback scheduling fromevent.isTrusted.benchmarks/news/runtime-stress.mjs: the controlled-form typing wait now reports the input value, output text, focus, selection, input identity, field renders, validation requests, and any browser errors when it times out, so failures are diagnosable. The correctness check itself is unchanged.packages/octane/tests/browser/event-boundaries/*+tests/_fixtures/event-commit-timing.tsrx: real-browser regression. Octane and React type trusted keystrokes into a controlled input under anonInputCaptureancestor with an outside native listener on the input; both must commit the edit and the outside listener must observe the typed text. A second case pins Octane's revert of an edit whose bubble segment a native listener stopped, and that the revert happens only after propagation (marked as an Octane divergence: React never restores in that case). jsdom cannot cover this becausedispatchEventnever checkpoints between listeners..changeset/trusted-capture-fallback-task.md: patch foroctane.Validation
pnpm format:check(repo-wide, passes)pnpm typecheck(repo-wide, passes)pnpm test(not run in full; see below)octane+octane-prod(894 files, 15455 tests pass);octane-events-browserforevent-boundaries,native-change,mobile-input,continuous-actions(68 tests pass)node benchmarks/controlled-form/run.mjs octane-tsrx 8: PASS, 8 correctness-gated samples (typing, caret, focus, controls, submit, stale validation, reset).react 1also passes as a control.native:target:instead ofnative:target:a) while the React case passes, and the harness now reports:pnpm syncproduced no generated changes.Risk / follow-ups
requestSubmit(), activation-firedinput/changeinsideclick()) now restore a stopped edit one task later than before; still after propagation, and React never restores in that case at all.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches core delegated event timing for all trusted discrete events; trusted script-dispatched edits may restore one task later than before, though still after propagation.
Overview
Fixes controlled inputs reverting on every keystroke when any
onXxxCapturehandler is registered for that event type. The delegated capture “stopped propagation” fallback was scheduled as a microtask, which browsers can run between the root’s capture and bubble listeners on trusted events—restoring the renderedvaluebeforeonInputruns.finishCaptureDispatchnow schedules that fallback withsetTimeout(0)for trusted events (after full native propagation) and keepsqueueMicrotaskfor script-dispatched events, replacing the old checkbox-onlychangespecial case.Adds browser regression coverage (Octane vs React) for typing into a controlled field under
onInputCapture, plus richer controlled-form benchmark timeout diagnostics. Patch changeset foroctane.Reviewed by Cursor Bugbot for commit 905084b. Bugbot is set up for automated code reviews on this repo. Configure here.