feat(events): hover during captureGesture + expose hitTest (A20)#85
Conversation
App.tsx now also dispatches hover during captured drag motion so drop targets can react to cursor position without reinventing hit-testing. Re-export hitTest from the package index for consumers using captured gestures with custom drop-detection logic. Co-Authored-By: Mark <psyhik17@gmail.com> Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 115e87c961
ℹ️ 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".
| if (col !== app.lastHoverCol || row !== app.lastHoverRow) { | ||
| app.lastHoverCol = col | ||
| app.lastHoverRow = row | ||
| app.props.onHoverAt(col, row) |
There was a problem hiding this comment.
Avoid hit-testing drag hover against the drag ghost
When the captured gesture is a normal <Draggable>, the dragged box stays under the cursor and is rendered as an absolute node with the drag-time z boost, while onHoverAt ultimately calls dispatchHover/hitTest, which returns the topmost painted node. In that common drag-over-sibling case this newly added hover dispatch keeps hitting the draggable itself instead of the drop zone or passive observer underneath, so the documented onMouseEnter-during-drag behavior does not fire for the target the cursor is visually being dragged over unless the drag source does not cover the cursor.
Useful? React with 👍 / 👎.
Closes #73 (A20).
What
Two surgical changes:
App.tsx: also dispatch hover (via existing `onHoverAt` → `dispatchHover`) during a captured drag's motion. `onMouseEnter` / `onMouseLeave` are side-effect-only and don't compete with the gesture's `onMove` for the input. Drop targets and other passive observers can now react to cursor position mid-drag without the gesture initiator coordinating anything.
index.ts: re-export `hitTest` so consumers can resolve "what element is at this cursor right now?" from inside a captured `onMove` handler — typical use is custom drop-target detection, drag-ghost positioning, hover-during-drag UX.
Tests
Docs
Net effect
Custom drag interactions are now fully composable. The drop-target-during-drag pattern that termos hand-rolled (FileList registers a RowHitTest closure; DragContext.move calls it on every cell-cross) becomes obsolete — consumers can either let `onMouseEnter` fire on each row passively, or call `hitTest` from inside their gesture's `onMove`.