Skip to content

Commit fc0e1a9

Browse files
committed
fix(use-long-press): Change cancelOutsideElement option default value and adjust tests
1 parent e06f2eb commit fc0e1a9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/use-long-press/src/lib/tests/use-long-press.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ describe('Hook result', () => {
6565
onPointerDown: expect.any(Function),
6666
onPointerMove: expect.any(Function),
6767
onPointerUp: expect.any(Function),
68+
onPointerLeave: expect.any(Function),
6869
});
6970
});
7071

@@ -78,6 +79,7 @@ describe('Hook result', () => {
7879
onMouseDown: expect.any(Function),
7980
onMouseUp: expect.any(Function),
8081
onMouseMove: expect.any(Function),
82+
onMouseLeave: expect.any(Function),
8183
});
8284

8385
const { result: resultTouch } = renderHook(() =>
@@ -570,7 +572,7 @@ describe('Hook options', () => {
570572
});
571573

572574
test.each([[LongPressEventType.Mouse] /*, [LongPressEventType.Touch]*/, [LongPressEventType.Pointer]])(
573-
'Cancel with proper reason when "%s" leaves element',
575+
'By default cancel with proper reason when "%s" leaves element',
574576
(eventType) => {
575577
const onCancel = vi.fn();
576578
const onFinish = vi.fn();
@@ -580,7 +582,6 @@ describe('Hook options', () => {
580582
callback: vi.fn(),
581583
onCancel,
582584
detect: eventType,
583-
cancelOutsideElement: true,
584585
threshold,
585586
});
586587
const longPressEvent = getDOMTestHandlersMap(eventType, element);

packages/use-long-press/src/lib/use-long-press.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export function useLongPress<
114114
captureEvent = false,
115115
detect = LongPressEventType.Pointer,
116116
cancelOnMovement = false,
117-
cancelOutsideElement = false,
117+
cancelOutsideElement = true,
118118
filterEvents,
119119
onStart,
120120
onMove,

0 commit comments

Comments
 (0)