Repository navigation
Conversation
…Miodec) goTo keeps queueing the move in a debounced animation frame; goToNow cancels that frame and moves immediately, for callers that already run in a frame after the words DOM is updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
The change is a faithful, behavior-preserving extraction with verified dependencies and matching frame-id handling, and the new immediate-move helpers are isolated and unused on master.
No open issues 🎉
What changed in this PR
This PR is a pure, behavior-preserving refactor of the test caret, split out of #8491 to shrink that PR's diff. It extracts the body of Caret.goTo into a new private moveTo method and introduces an immediate (non-debounced) path (goToNow / updatePositionNow) that #8491 will use to move the caret inside the shared words animation frame instead of queuing its own frame. On master these new functions are introduced but unused.
Changes:
- Extract
goTo's rAF callback body intoprivate moveTo(options);goTonow just schedulesmoveToviarequestDebouncedAnimationFrame. - Add
goToNow(options)which cancels any pending debounced frame (caret.<id>.goTo) and runsmoveTosynchronously; hoist the inline options type into a reusableGoToOptionstype. - In
test/caret.ts, factor shared option-building intopositionOptions(noAnim)and addupdatePositionNowwrappinggoToNow.
| File | Description |
|---|---|
| frontend/src/ts/elements/caret.ts | Extracts moveTo, adds goToNow, imports cancelPendingAnimationFrame, hoists GoToOptions type. |
| frontend/src/ts/test/caret.ts | Adds shared positionOptions builder and new updatePositionNow that calls goToNow. |
I verified that cancelPendingAnimationFrame is exported (utils/debounced-animation-frame.ts:23) and uses the same frame id (caret.<id>.goTo) as requestDebouncedAnimationFrame, that the extracted moveTo body is logically identical to the prior goTo callback (only re-indentation/reformatting), and that Parameters<Caret["goTo"]>[0] resolves to the new GoToOptions type so positionOptions stays correctly typed. No issues found.
Review effort: Balanced
|
Folded into #8491: the caret moves synchronously there, so goToNow isn't needed. |
Summary
Split out of #8491 (Solid Words component) to shrink its diff. No behaviour change on master: the existing
goTo/updatePositionpath is the same code, moved intomoveTo.goToNow/updatePositionNoware used by #8491, where the caret moves inside the shared words frame right after the DOM update instead of queueing its own frame.Evidence
wasits before letter 2, after extra letters + space +hsits before letter 1 of the next word.frontend/__tests__/test+__tests__/elements(258) pass.Merge Danger
Door: two-way
Blast Radius: caret
Pure extraction; the moved body is unchanged (diff is mostly re-indentation).
🤖 Generated with Claude Code