@@ -18,6 +18,7 @@ import {
18
18
debounce ,
19
19
normalizeArrowKey ,
20
20
} from '../../utils'
21
+ import { isReactNative } from '../../is.macro'
21
22
import downshiftSelectReducer from './reducer'
22
23
import { validatePropTypes , defaultProps } from './utils'
23
24
import * as stateChangeTypes from './stateChangeTypes'
@@ -354,7 +355,7 @@ function useSelect(userProps = {}) {
354
355
)
355
356
const getToggleButtonProps = useCallback (
356
357
(
357
- { onBlur, onClick, onKeyDown, refKey = 'ref' , ref, ...rest } = { } ,
358
+ { onBlur, onClick, onPress , onKeyDown, refKey = 'ref' , ref, ...rest } = { } ,
358
359
{ suppressRefError = false } = { } ,
359
360
) => {
360
361
const latestState = latest . current . state
@@ -405,14 +406,22 @@ function useSelect(userProps = {}) {
405
406
}
406
407
407
408
if ( ! rest . disabled ) {
408
- toggleProps . onClick = callAllEventHandlers (
409
- onClick ,
410
- toggleButtonHandleClick ,
411
- )
412
- toggleProps . onKeyDown = callAllEventHandlers (
413
- onKeyDown ,
414
- toggleButtonHandleKeyDown ,
415
- )
409
+ /* istanbul ignore if (react-native) */
410
+ if ( isReactNative ) {
411
+ toggleProps . onPress = callAllEventHandlers (
412
+ onPress ,
413
+ toggleButtonHandleClick ,
414
+ )
415
+ } else {
416
+ toggleProps . onClick = callAllEventHandlers (
417
+ onClick ,
418
+ toggleButtonHandleClick ,
419
+ )
420
+ toggleProps . onKeyDown = callAllEventHandlers (
421
+ onKeyDown ,
422
+ toggleButtonHandleKeyDown ,
423
+ )
424
+ }
416
425
}
417
426
418
427
setGetterPropCallInfo (
@@ -440,6 +449,7 @@ function useSelect(userProps = {}) {
440
449
index : indexProp ,
441
450
onMouseMove,
442
451
onClick,
452
+ onPress,
443
453
refKey = 'ref' ,
444
454
ref,
445
455
disabled,
@@ -485,8 +495,14 @@ function useSelect(userProps = {}) {
485
495
}
486
496
487
497
if ( ! disabled ) {
488
- itemProps . onClick = callAllEventHandlers ( onClick , itemHandleClick )
498
+ /* istanbul ignore next (react-native) */
499
+ if ( isReactNative ) {
500
+ itemProps . onPress = callAllEventHandlers ( onPress , itemHandleClick )
501
+ } else {
502
+ itemProps . onClick = callAllEventHandlers ( onClick , itemHandleClick )
503
+ }
489
504
}
505
+
490
506
itemProps . onMouseMove = callAllEventHandlers (
491
507
onMouseMove ,
492
508
itemHandleMouseMove ,
0 commit comments