Skip to content

Commit

Permalink
Fix move event being called twice when capturing pointer if pointer i…
Browse files Browse the repository at this point in the history
…ntersects anyway
  • Loading branch information
adventful committed Oct 29, 2022
1 parent c2104b1 commit 867091b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/fiber/src/core/events.ts
Expand Up @@ -252,7 +252,7 @@ export function createEvents(store: UseBoundStore<RootState>) {
// If the interaction is captured, make all capturing targets part of the intersect.
if ('pointerId' in event && state.internal.capturedMap.has(event.pointerId)) {
for (let captureData of state.internal.capturedMap.get(event.pointerId)!.values()) {
intersections.push(captureData.intersection)
if (!duplicates.has(makeId(captureData.intersection))) intersections.push(captureData.intersection)
}
}
return intersections
Expand Down
1 change: 1 addition & 0 deletions packages/fiber/tests/core/events.test.tsx
Expand Up @@ -366,6 +366,7 @@ describe('events', () => {
expect(handlePointerLeave).not.toHaveBeenCalled();

await act(async () => canvas.dispatchEvent(moveIn))
expect(handlePointerMove).toHaveBeenCalledTimes(3);

const up = new PointerEvent('pointerup', { pointerId })
Object.defineProperty(up, 'offsetX', { get: () => 577 })
Expand Down

0 comments on commit 867091b

Please sign in to comment.