Skip to content

Commit 694f2af

Browse files
authored
fix(hooks): do not add mouse and touch events in React native (#1472)
1 parent 3046bea commit 694f2af

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/hooks/utils.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ function getHighlightedIndexOnOpen(props, state, offset) {
305305
* @param {Function} handleBlur Handler on blur from mouse or touch.
306306
* @returns {Object} Ref containing whether mouseDown or touchMove event is happening
307307
*/
308-
function useMouseAndTouchTracker(
308+
function useMouseAndTouchTracker(
309309
isOpen,
310310
downshiftElementRefs,
311311
environment,
@@ -317,6 +317,11 @@ function getHighlightedIndexOnOpen(props, state, offset) {
317317
})
318318

319319
useEffect(() => {
320+
/* istanbul ignore if (react-native) */
321+
if (isReactNative) {
322+
return
323+
}
324+
320325
// The same strategy for checking if a click occurred inside or outside downsift
321326
// as in downshift.js.
322327
const onMouseDown = () => {
@@ -362,6 +367,7 @@ function getHighlightedIndexOnOpen(props, state, offset) {
362367
environment.addEventListener('touchmove', onTouchMove)
363368
environment.addEventListener('touchend', onTouchEnd)
364369

370+
// eslint-disable-next-line consistent-return
365371
return function cleanup() {
366372
environment.removeEventListener('mousedown', onMouseDown)
367373
environment.removeEventListener('mouseup', onMouseUp)

0 commit comments

Comments
 (0)