Fix click cursor animation detaching on page scroll#8
Conversation
Track the active target element during click/type operations and reposition the cursor overlay on scroll events. When the target remains in the viewport, the cursor follows it; when the target scrolls out of view, the cursor is hidden. Closes #1
|
@codex review this pr |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf58df008c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return; | ||
| } | ||
| if (this.activeTarget) { | ||
| const rect = this.activeTarget.getBoundingClientRect(); |
There was a problem hiding this comment.
Skip scroll tracking for detached active targets
When a click/type action causes the target node to be unmounted before endTask() runs (common in SPA rerenders), this.activeTarget can remain set to a detached element and getBoundingClientRect() returns a zero rect. The current check then treats (0,0) as in-viewport and moves the cursor to the top-left corner on subsequent scroll events, which is a visible regression during post-action stability waits. Guarding with isConnected (or clearing activeTarget) avoids this misplacement.
Useful? React with 👍 / 👎.
| centerX >= 0 && centerX <= window.innerWidth && | ||
| centerY >= 0 && centerY <= window.innerHeight |
There was a problem hiding this comment.
Determine target visibility from rect intersection
The scroll handler hides the cursor as soon as the target’s center point exits the viewport, but that does not mean the element is fully out of view. For partially visible elements near an edge, the cursor is hidden prematurely even though the target is still visible, which conflicts with the intended "hide only when out of view" behavior. Use rectangle intersection against the viewport instead of center-point inclusion.
Useful? React with 👍 / 👎.
Summary
activeTargetfield onCursorAgentscrollevent listener that repositions the cursor overlay to the target's updated viewport coordinatesactiveTargetonendTask()andstop()Test plan
scrollIntoView)Closes #1