diff --git a/packages/react-native-ui-lib/jestSetup/jest-setup.js b/packages/react-native-ui-lib/jestSetup/jest-setup.js index ee9e0f5325..97c32e1614 100644 --- a/packages/react-native-ui-lib/jestSetup/jest-setup.js +++ b/packages/react-native-ui-lib/jestSetup/jest-setup.js @@ -77,6 +77,7 @@ jest.mock('react-native-gesture-handler', PanMock.onFinalize = getDefaultMockedHandler('onFinalize'); PanMock.activateAfterLongPress = getDefaultMockedHandler('activateAfterLongPress'); PanMock.enabled = getDefaultMockedHandler('enabled'); + PanMock.hitSlop = getDefaultMockedHandler('hitSlop'); PanMock.onTouchesMove = getDefaultMockedHandler('onTouchesMove'); PanMock.prepare = jest.fn(); PanMock.initialize = jest.fn(); diff --git a/packages/react-native-ui-lib/src/components/slider/index.tsx b/packages/react-native-ui-lib/src/components/slider/index.tsx index da663cf2d9..0460b86c47 100644 --- a/packages/react-native-ui-lib/src/components/slider/index.tsx +++ b/packages/react-native-ui-lib/src/components/slider/index.tsx @@ -498,6 +498,10 @@ class Slider extends PureComponent { this.handleMeasure('thumbSize', nativeEvent); }; + handleContainerShouldSetResponder = () => { + return !this.props.disabled; + }; + handleTrackPress = (event: GestureResponderEvent) => { if (this.props.disabled) { return; @@ -672,10 +676,11 @@ class Slider extends PureComponent { onLayout={this.onContainerLayout} onAccessibilityAction={this.onAccessibilityAction} testID={testID} + onStartShouldSetResponder={this.handleContainerShouldSetResponder} + onResponderRelease={this.handleTrackPress} {...this.getAccessibilityProps()} > {this.renderTrack()} - {this.renderRangeThumb()} {this.renderThumb()} @@ -700,9 +705,5 @@ const styles = StyleSheet.create({ }, trackDisableRTL: { right: 0 - }, - touchArea: { - ...StyleSheet.absoluteFillObject, - backgroundColor: 'transparent' } }); diff --git a/packages/react-native-ui-lib/src/incubator/slider/Thumb.tsx b/packages/react-native-ui-lib/src/incubator/slider/Thumb.tsx index 9e7aa67526..38d7af1b7e 100644 --- a/packages/react-native-ui-lib/src/incubator/slider/Thumb.tsx +++ b/packages/react-native-ui-lib/src/incubator/slider/Thumb.tsx @@ -62,6 +62,7 @@ const Thumb = (props: ThumbProps) => { const lastOffset = useSharedValue(0); const gesture = Gesture.Pan() + .hitSlop(hitSlop ?? DEFAULT_THUMB_HIT_SLOP) .onBegin(() => { onSeekStart?.(); isPressed.value = true;