diff --git a/packages/react-events/docs/Press.md b/packages/react-events/docs/Press.md index bc95b88c969b1..50e6c2b945015 100644 --- a/packages/react-events/docs/Press.md +++ b/packages/react-events/docs/Press.md @@ -74,17 +74,6 @@ type PressOffset = { ## Props -### delayPressEnd: number - -The duration of the delay between when the press ends and when `onPressEnd` is -called. - -### delayPressStart: number - -The duration of a delay between when the press starts and when `onPressStart` is -called. This delay is cut short (and `onPressStart` is called) if the press is -released before the threshold is exceeded. - ### disabled: boolean = false Disables all `Press` events. @@ -107,21 +96,16 @@ Called when the element changes press state (i.e., after `onPressStart` and ### onPressEnd: (e: PressEvent) => void Called once the element is no longer pressed (because the press was released, -cancelled, or moved beyond the hit bounds). If the press starts again before the -`delayPressEnd` threshold is exceeded then the delay is reset to prevent -`onPressEnd` being called during a press. +cancelled, or moved beyond the hit bounds). ### onPressMove: (e: PressEvent) => void -Called when a press moves within the hit bounds of the element. `onPressMove` is -called immediately and doesn't wait for delayed `onPressStart`. Never called for +Called when a press moves within the hit bounds of the element. Never called for keyboard-initiated press events. ### onPressStart: (e: PressEvent) => void -Called once the element is pressed down. If the press is released before the -`delayPressStart` threshold is exceeded then the delay is cut short and -`onPressStart` is called immediately. +Called once the element is pressed down. ### pressRetentionOffset: PressOffset @@ -142,4 +126,4 @@ Whether to `preventDefault()` native events. Native behavior is prevented by default. If an anchor is the child of `Press`, internal and external navigation should be performed in `onPress`. To rely on native behavior instead, set `preventDefault` to `false`, but be aware that native behavior will take place -immediately after interaction without respect for delays or long press. +immediately after interaction. diff --git a/packages/react-events/src/dom/Press.js b/packages/react-events/src/dom/Press.js index 732ee866f6c39..52274f3846ab3 100644 --- a/packages/react-events/src/dom/Press.js +++ b/packages/react-events/src/dom/Press.js @@ -28,8 +28,6 @@ type PressListenerProps = {| type PressProps = {| disabled: boolean, - delayPressEnd: number, - delayPressStart: number, pressRetentionOffset: { top: number, right: number, @@ -53,7 +51,6 @@ type PressState = { isPressWithinResponderRegion: boolean, pointerType: PointerType, pressTarget: null | Element | Document, - pressEndTimeout: null | number, pressStartTimeout: null | number, responderRegionOnActivation: null | $ReadOnly<{| bottom: number, @@ -106,8 +103,6 @@ const isMac = typeof window !== 'undefined' && window.navigator != null ? /^Mac/.test(window.navigator.platform) : false; -const DEFAULT_PRESS_END_DELAY_MS = 0; -const DEFAULT_PRESS_START_DELAY_MS = 0; const DEFAULT_PRESS_RETENTION_OFFSET = { bottom: 20, top: 20, @@ -240,35 +235,6 @@ function dispatchPressChangeEvent( context.dispatchEvent('onPressChange', bool, DiscreteEvent); } -function activate(event: ReactDOMResponderEvent, context, props, state) { - const nativeEvent: any = event.nativeEvent; - const {clientX: x, clientY: y} = state.touchEvent || nativeEvent; - const wasActivePressed = state.isActivePressed; - state.isActivePressed = true; - if (x !== undefined && y !== undefined) { - state.activationPosition = {x, y}; - } - - dispatchEvent( - 'onPressStart', - event, - context, - state, - 'pressstart', - DiscreteEvent, - ); - if (!wasActivePressed) { - dispatchPressChangeEvent(context, state); - } -} - -function deactivate(event: ?ReactDOMResponderEvent, context, props, state) { - state.isActivePressed = false; - - dispatchEvent('onPressEnd', event, context, state, 'pressend', DiscreteEvent); - dispatchPressChangeEvent(context, state); -} - function dispatchPressStartEvents( event: ReactDOMResponderEvent, context: ReactDOMResponderContext, @@ -277,29 +243,26 @@ function dispatchPressStartEvents( ): void { state.isPressed = true; - if (state.pressEndTimeout !== null) { - context.clearTimeout(state.pressEndTimeout); - state.pressEndTimeout = null; - } - - const dispatch = () => { + if (!state.isActivePressStart) { state.isActivePressStart = true; - activate(event, context, props, state); - }; + const nativeEvent: any = event.nativeEvent; + const {clientX: x, clientY: y} = state.touchEvent || nativeEvent; + const wasActivePressed = state.isActivePressed; + state.isActivePressed = true; + if (x !== undefined && y !== undefined) { + state.activationPosition = {x, y}; + } - if (!state.isActivePressStart) { - const delayPressStart = calculateDelayMS( - props.delayPressStart, - 0, - DEFAULT_PRESS_START_DELAY_MS, + dispatchEvent( + 'onPressStart', + event, + context, + state, + 'pressstart', + DiscreteEvent, ); - if (delayPressStart > 0) { - state.pressStartTimeout = context.setTimeout(() => { - state.pressStartTimeout = null; - dispatch(); - }, delayPressStart); - } else { - dispatch(); + if (!wasActivePressed) { + dispatchPressChangeEvent(context, state); } } } @@ -310,40 +273,20 @@ function dispatchPressEndEvents( props: PressProps, state: PressState, ): void { - const wasActivePressStart = state.isActivePressStart; - let activationWasForced = false; - state.isActivePressStart = false; state.isPressed = false; - if (!wasActivePressStart && state.pressStartTimeout !== null) { - context.clearTimeout(state.pressStartTimeout); - state.pressStartTimeout = null; - // don't activate if a press has moved beyond the responder region - if (state.isPressWithinResponderRegion && event != null) { - // if we haven't yet activated (due to delays), activate now - activate(event, context, props, state); - activationWasForced = true; - } - } - if (state.isActivePressed) { - const delayPressEnd = calculateDelayMS( - props.delayPressEnd, - // if activation and deactivation occur during the same event there's no - // time for visual user feedback therefore a small delay is added before - // deactivating. - activationWasForced ? 10 : 0, - DEFAULT_PRESS_END_DELAY_MS, + state.isActivePressed = false; + dispatchEvent( + 'onPressEnd', + event, + context, + state, + 'pressend', + DiscreteEvent, ); - if (delayPressEnd > 0) { - state.pressEndTimeout = context.setTimeout(() => { - state.pressEndTimeout = null; - deactivate(event, context, props, state); - }, delayPressEnd); - } else { - deactivate(event, context, props, state); - } + dispatchPressChangeEvent(context, state); } state.responderRegionOnDeactivation = null; @@ -380,11 +323,6 @@ function isValidKeyboardEvent(nativeEvent: Object): boolean { ); } -function calculateDelayMS(delay: ?number, min = 0, fallback = 0) { - const maybeNumber = delay == null ? null : delay; - return Math.max(min, maybeNumber != null ? maybeNumber : fallback); -} - // TODO: account for touch hit slop function calculateResponderRegion( context: ReactDOMResponderContext, @@ -550,7 +488,6 @@ const pressResponderImpl = { isPressed: false, isPressWithinResponderRegion: true, pointerType: '', - pressEndTimeout: null, pressStartTimeout: null, pressTarget: null, responderRegionOnActivation: null, diff --git a/packages/react-events/src/dom/__tests__/Press-test.internal.js b/packages/react-events/src/dom/__tests__/Press-test.internal.js index adbac1adc1af5..6c9b4f66d119d 100644 --- a/packages/react-events/src/dom/__tests__/Press-test.internal.js +++ b/packages/react-events/src/dom/__tests__/Press-test.internal.js @@ -16,8 +16,6 @@ let PressResponder; let usePressListener; let Scheduler; -const DEFAULT_LONG_PRESS_DELAY = 500; - const createEvent = (type, data) => { const event = document.createEvent('CustomEvent'); event.initCustomEvent(type, true, true); @@ -262,129 +260,6 @@ describe('Event responder: Press', () => { expect.objectContaining({pointerType: 'touch', type: 'pressstart'}), ); }); - - describe('delayPressStart', () => { - it('can be configured', () => { - const Component = () => { - usePressListener({ - onPressStart, - }); - return ( -
} - /> - ); - }; - ReactDOM.render(, container); - - ref.current.dispatchEvent(createEvent('pointerdown')); - jest.advanceTimersByTime(1999); - expect(onPressStart).not.toBeCalled(); - jest.advanceTimersByTime(1); - expect(onPressStart).toHaveBeenCalledTimes(1); - }); - - it('is cut short if the press is released during a delay', () => { - const Component = () => { - usePressListener({ - onPressStart, - }); - return ( -
} - /> - ); - }; - ReactDOM.render(, container); - - ref.current.getBoundingClientRect = () => ({ - top: 50, - left: 50, - bottom: 500, - right: 500, - }); - - ref.current.dispatchEvent(createEvent('pointerdown')); - jest.advanceTimersByTime(499); - expect(onPressStart).toHaveBeenCalledTimes(0); - ref.current.dispatchEvent( - createEvent('pointerup', { - clientX: 55, - clientY: 55, - }), - ); - expect(onPressStart).toHaveBeenCalledTimes(1); - jest.runAllTimers(); - expect(onPressStart).toHaveBeenCalledTimes(1); - }); - - it('onPressStart is called synchronously if delay is 0ms', () => { - const Component = () => { - usePressListener({ - onPressStart, - }); - return ( -
} - /> - ); - }; - ReactDOM.render(, container); - - ref.current.dispatchEvent(createEvent('pointerdown')); - expect(onPressStart).toHaveBeenCalledTimes(1); - }); - - it('onPressStart should not be called if pointerCancel is fired before delayPressStart is finished', () => { - const Component = () => { - usePressListener({ - onPressStart, - }); - return ( -
} - /> - ); - }; - ReactDOM.render(, container); - - ref.current.dispatchEvent(createEvent('pointerdown')); - jest.advanceTimersByTime(499); - expect(onPressStart).toHaveBeenCalledTimes(0); - ref.current.dispatchEvent(createEvent('pointercancel')); - jest.runAllTimers(); - expect(onPressStart).toHaveBeenCalledTimes(0); - }); - }); - - describe('delayPressEnd', () => { - it('onPressStart called each time a press is initiated', () => { - // This test makes sure that onPressStart is called each time a press - // starts, even if a delayPressEnd is delaying the deactivation of the - // previous press. - const Component = () => { - usePressListener({ - onPressStart, - }); - return ( -
} - /> - ); - }; - ReactDOM.render(, container); - - ref.current.dispatchEvent(createEvent('pointerdown')); - ref.current.dispatchEvent(createEvent('pointerup')); - ref.current.dispatchEvent(createEvent('pointerdown')); - expect(onPressStart).toHaveBeenCalledTimes(2); - }); - }); }); describe('onPressEnd', () => { @@ -549,71 +424,6 @@ describe('Event responder: Press', () => { expect.objectContaining({pointerType: 'touch', type: 'pressend'}), ); }); - - describe('delayPressEnd', () => { - it('can be configured', () => { - const Component = () => { - usePressListener({ - onPressEnd, - }); - return ( -
} - /> - ); - }; - ReactDOM.render(, container); - - ref.current.dispatchEvent(createEvent('pointerdown')); - ref.current.dispatchEvent(createEvent('pointerup')); - jest.advanceTimersByTime(1999); - expect(onPressEnd).not.toBeCalled(); - jest.advanceTimersByTime(1); - expect(onPressEnd).toHaveBeenCalledTimes(1); - }); - - it('is reset if "pointerdown" is dispatched during a delay', () => { - const Component = () => { - usePressListener({ - onPressEnd, - }); - return ( -
} - /> - ); - }; - ReactDOM.render(, container); - - ref.current.dispatchEvent(createEvent('pointerdown')); - ref.current.dispatchEvent(createEvent('pointerup')); - jest.advanceTimersByTime(499); - ref.current.dispatchEvent(createEvent('pointerdown')); - jest.advanceTimersByTime(1); - expect(onPressEnd).not.toBeCalled(); - ref.current.dispatchEvent(createEvent('pointerup')); - jest.runAllTimers(); - expect(onPressEnd).toHaveBeenCalledTimes(1); - }); - }); - - it('onPressEnd is called synchronously if delay is 0ms', () => { - const Component = () => { - usePressListener({ - onPressEnd, - }); - return ( -
} /> - ); - }; - ReactDOM.render(, container); - - ref.current.dispatchEvent(createEvent('pointerdown')); - ref.current.dispatchEvent(createEvent('pointerup')); - expect(onPressEnd).toHaveBeenCalledTimes(1); - }); }); describe('onPressChange', () => { @@ -648,111 +458,6 @@ describe('Event responder: Press', () => { expect(onPressChange).toHaveBeenCalledTimes(2); expect(onPressChange).toHaveBeenCalledWith(false); }); - - it('is called after delayed onPressStart', () => { - const Component = () => { - usePressListener({ - onPressChange, - }); - return ( -
} - /> - ); - }; - ReactDOM.render(, container); - - ref.current.dispatchEvent(createEvent('pointerdown')); - jest.advanceTimersByTime(499); - expect(onPressChange).not.toBeCalled(); - jest.advanceTimersByTime(1); - expect(onPressChange).toHaveBeenCalledTimes(1); - expect(onPressChange).toHaveBeenCalledWith(true); - }); - - it('is called after delayPressStart is cut short', () => { - const Component = () => { - usePressListener({ - onPressChange, - }); - return ( -
} - /> - ); - }; - ReactDOM.render(, container); - - ref.current.getBoundingClientRect = () => ({ - top: 50, - left: 50, - bottom: 500, - right: 500, - }); - - ref.current.dispatchEvent(createEvent('pointerdown')); - jest.advanceTimersByTime(100); - ref.current.dispatchEvent( - createEvent('pointerup', { - clientX: 55, - clientY: 55, - }), - ); - jest.advanceTimersByTime(10); - expect(onPressChange).toHaveBeenCalledWith(true); - expect(onPressChange).toHaveBeenCalledWith(false); - expect(onPressChange).toHaveBeenCalledTimes(2); - }); - - it('is called after delayed onPressEnd', () => { - const Component = () => { - usePressListener({ - onPressChange, - }); - return ( -
} /> - ); - }; - ReactDOM.render(, container); - - ref.current.dispatchEvent(createEvent('pointerdown')); - expect(onPressChange).toHaveBeenCalledTimes(1); - expect(onPressChange).toHaveBeenCalledWith(true); - ref.current.dispatchEvent(createEvent('pointerup')); - jest.advanceTimersByTime(499); - expect(onPressChange).toHaveBeenCalledTimes(1); - jest.advanceTimersByTime(1); - expect(onPressChange).toHaveBeenCalledTimes(2); - expect(onPressChange).toHaveBeenCalledWith(false); - }); - - // No PointerEvent fallbacks - it('is called after "mousedown" and "mouseup" events', () => { - ref.current.dispatchEvent(createEvent('mousedown')); - expect(onPressChange).toHaveBeenCalledTimes(1); - expect(onPressChange).toHaveBeenCalledWith(true); - ref.current.dispatchEvent(createEvent('mouseup')); - expect(onPressChange).toHaveBeenCalledTimes(2); - expect(onPressChange).toHaveBeenCalledWith(false); - }); - it('is called after "touchstart" and "touchend" events', () => { - ref.current.dispatchEvent( - createTouchEvent('touchstart', 0, { - target: ref.current, - }), - ); - expect(onPressChange).toHaveBeenCalledTimes(1); - expect(onPressChange).toHaveBeenCalledWith(true); - ref.current.dispatchEvent( - createTouchEvent('touchend', 0, { - target: ref.current, - }), - ); - expect(onPressChange).toHaveBeenCalledTimes(2); - expect(onPressChange).toHaveBeenCalledWith(false); - }); }); describe('onPress', () => { @@ -854,24 +559,6 @@ describe('Event responder: Press', () => { expect(onPress).not.toBeCalled(); }); - it('is always called immediately after press is released', () => { - const Component = () => { - usePressListener({ - onPress, - }); - return ( -
} /> - ); - }; - ReactDOM.render(, container); - - ref.current.dispatchEvent(createEvent('pointerdown')); - ref.current.dispatchEvent( - createEvent('pointerup', {clientX: 10, clientY: 10}), - ); - expect(onPress).toHaveBeenCalledTimes(1); - }); - it('is called with modifier keys', () => { ref.current.dispatchEvent( createEvent('pointerdown', {metaKey: true, pointerType: 'mouse'}), @@ -1062,7 +749,7 @@ describe('Event responder: Press', () => { * │ HitRect X │ <= Move to X and release * └──────────────────┘ */ - it('no delay and "onPress*" events are called immediately', () => { + it('"onPress*" events are called immediately', () => { let events = []; const ref = React.createRef(); const createEventHandler = msg => () => { @@ -1099,7 +786,7 @@ describe('Event responder: Press', () => { ]); }); - it('no delay and "onPress*" events are correctly called with target change', () => { + it('"onPress*" events are correctly called with target change', () => { let events = []; const outerRef = React.createRef(); const innerRef = React.createRef(); @@ -1149,47 +836,6 @@ describe('Event responder: Press', () => { ]); }); - it('delay and "onPressMove" is called before "onPress*" events', () => { - let events = []; - const ref = React.createRef(); - const createEventHandler = msg => () => { - events.push(msg); - }; - - const Component = () => { - usePressListener({ - onPress: createEventHandler('onPress'), - onPressChange: createEventHandler('onPressChange'), - onPressMove: createEventHandler('onPressMove'), - onPressStart: createEventHandler('onPressStart'), - onPressEnd: createEventHandler('onPressEnd'), - }); - return ( -
} - /> - ); - }; - ReactDOM.render(, container); - - ref.current.getBoundingClientRect = getBoundingClientRectMock; - ref.current.dispatchEvent(createEvent('pointerdown')); - ref.current.dispatchEvent( - createEvent('pointermove', coordinatesInside), - ); - jest.advanceTimersByTime(499); - expect(events).toEqual(['onPressMove']); - events = []; - - jest.advanceTimersByTime(1); - expect(events).toEqual(['onPressStart', 'onPressChange']); - events = []; - - ref.current.dispatchEvent(createEvent('pointerup', coordinatesInside)); - expect(events).toEqual(['onPressEnd', 'onPressChange', 'onPress']); - }); - it('press retention offset can be configured', () => { let events = []; const ref = React.createRef(); @@ -1359,46 +1005,6 @@ describe('Event responder: Press', () => { 'onPressChange', ]); }); - - it('"onPress*" events are not called after delay expires', () => { - let events = []; - const ref = React.createRef(); - const createEventHandler = msg => () => { - events.push(msg); - }; - - const Component = () => { - usePressListener({ - onPress: createEventHandler('onPress'), - onPressChange: createEventHandler('onPressChange'), - onPressMove: createEventHandler('onPressMove'), - onPressStart: createEventHandler('onPressStart'), - onPressEnd: createEventHandler('onPressEnd'), - }); - return ( -
- } - /> - ); - }; - ReactDOM.render(, container); - - ref.current.getBoundingClientRect = getBoundingClientRectMock; - ref.current.dispatchEvent(createEvent('pointerdown')); - ref.current.dispatchEvent( - createEvent('pointermove', coordinatesInside), - ); - container.dispatchEvent(createEvent('pointermove', coordinatesOutside)); - jest.runAllTimers(); - expect(events).toEqual(['onPressMove']); - events = []; - container.dispatchEvent(createEvent('pointerup', coordinatesOutside)); - jest.runAllTimers(); - expect(events).toEqual([]); - }); }); it('"onPress" is not called on release with mouse', () => { @@ -1643,7 +1249,7 @@ describe('Event responder: Press', () => { * │ HitRect X │ <= Move to X and release * └──────────────────┘ */ - it('no delay and "onPress*" events are called immediately', () => { + it('"onPress*" events are called immediately', () => { let events = []; const ref = React.createRef(); const createEventHandler = msg => () => { @@ -1693,60 +1299,6 @@ describe('Event responder: Press', () => { ]); }); - it('delay and "onPressMove" is called before "onPress*" events', () => { - let events = []; - const ref = React.createRef(); - const createEventHandler = msg => () => { - events.push(msg); - }; - - const Component = () => { - usePressListener({ - onPress: createEventHandler('onPress'), - onPressChange: createEventHandler('onPressChange'), - onPressMove: createEventHandler('onPressMove'), - onPressStart: createEventHandler('onPressStart'), - onPressEnd: createEventHandler('onPressEnd'), - }); - return ( -
} - /> - ); - }; - ReactDOM.render(, container); - - document.elementFromPoint = () => ref.current; - ref.current.getBoundingClientRect = getBoundingClientRectMock; - ref.current.dispatchEvent( - createTouchEvent('touchstart', 0, { - target: ref.current, - }), - ); - ref.current.dispatchEvent( - createTouchEvent('touchmove', 0, { - ...coordinatesInside, - target: ref.current, - }), - ); - jest.advanceTimersByTime(499); - expect(events).toEqual(['onPressMove']); - events = []; - - jest.advanceTimersByTime(1); - expect(events).toEqual(['onPressStart', 'onPressChange']); - events = []; - - ref.current.dispatchEvent( - createTouchEvent('touchend', 0, { - ...coordinatesInside, - target: ref.current, - }), - ); - expect(events).toEqual(['onPressEnd', 'onPressChange', 'onPress']); - }); - it('press retention offset can be configured', () => { let events = []; const ref = React.createRef(); @@ -1976,65 +1528,6 @@ describe('Event responder: Press', () => { 'onPressChange', ]); }); - - it('"onPress*" events are not called after delay expires', () => { - let events = []; - const ref = React.createRef(); - const createEventHandler = msg => () => { - events.push(msg); - }; - - const Component = () => { - usePressListener({ - onPress: createEventHandler('onPress'), - onPressChange: createEventHandler('onPressChange'), - onPressMove: createEventHandler('onPressMove'), - onPressStart: createEventHandler('onPressStart'), - onPressEnd: createEventHandler('onPressEnd'), - }); - return ( -
- } - /> - ); - }; - ReactDOM.render(, container); - - document.elementFromPoint = () => ref.current; - ref.current.getBoundingClientRect = getBoundingClientRectMock; - ref.current.dispatchEvent( - createTouchEvent('touchstart', 0, { - target: ref.current, - }), - ); - ref.current.dispatchEvent( - createTouchEvent('touchmove', 0, { - ...coordinatesInside, - target: ref.current, - }), - ); - document.elementFromPoint = () => container; - container.dispatchEvent( - createTouchEvent('touchmove', 0, { - ...coordinatesOutside, - target: container, - }), - ); - jest.runAllTimers(); - expect(events).toEqual(['onPressMove']); - events = []; - container.dispatchEvent( - createTouchEvent('touchend', 0, { - ...coordinatesOutside, - target: container, - }), - ); - jest.runAllTimers(); - expect(events).toEqual([]); - }); }); it('"onPress" is called on re-entry to hit rect for touch', () => { @@ -2106,82 +1599,6 @@ describe('Event responder: Press', () => { }); }); - describe('delayed and multiple events', () => { - it('dispatches in the correct order', () => { - let events; - const ref = React.createRef(); - const createEventHandler = msg => () => { - events.push(msg); - }; - - const Component = () => { - usePressListener({ - onPress: createEventHandler('onPress'), - onPressChange: createEventHandler('onPressChange'), - onPressMove: createEventHandler('onPressMove'), - onPressStart: createEventHandler('onPressStart'), - onPressEnd: createEventHandler('onPressEnd'), - }); - return ( -
- } - /> - ); - }; - ReactDOM.render(, container); - - ref.current.getBoundingClientRect = () => ({ - top: 0, - left: 0, - bottom: 100, - right: 100, - }); - - // 1 - events = []; - ref.current.dispatchEvent(createEvent('pointerdown')); - ref.current.dispatchEvent( - createEvent('pointerup', {clientX: 10, clientY: 10}), - ); - ref.current.dispatchEvent(createEvent('pointerdown')); - ref.current.dispatchEvent( - createEvent('pointerup', {clientX: 10, clientY: 10}), - ); - jest.runAllTimers(); - - expect(events).toEqual([ - 'onPressStart', - 'onPressChange', - 'onPress', - 'onPressStart', - 'onPress', - 'onPressEnd', - 'onPressChange', - ]); - - // 2 - events = []; - ref.current.dispatchEvent(createEvent('pointerdown')); - jest.advanceTimersByTime(250); - jest.advanceTimersByTime(500); - ref.current.dispatchEvent( - createEvent('pointerup', {clientX: 10, clientY: 10}), - ); - jest.runAllTimers(); - - expect(events).toEqual([ - 'onPressStart', - 'onPressChange', - 'onPress', - 'onPressEnd', - 'onPressChange', - ]); - }); - }); - describe('nested responders', () => { it('dispatch events in the correct order', () => { const events = []; @@ -2701,7 +2118,6 @@ describe('Event responder: Press', () => { ReactDOM.render(, container); ref.current.dispatchEvent(createEvent('pointerdown')); - jest.advanceTimersByTime(DEFAULT_LONG_PRESS_DELAY); ref.current.dispatchEvent(createEvent('pointermove')); ref.current.dispatchEvent(createEvent('pointerup')); ref.current.dispatchEvent(createEvent('pointerdown')); @@ -2757,7 +2173,6 @@ describe('Event responder: Press', () => { clientY: 31, }), ); - jest.advanceTimersByTime(DEFAULT_LONG_PRESS_DELAY); ref.current.dispatchEvent( createEvent('pointermove', { pointerType: 'mouse',