diff --git a/scripts/typescript-output-lint.js b/scripts/typescript-output-lint.js index 85a94f4cef..5072f63c48 100644 --- a/scripts/typescript-output-lint.js +++ b/scripts/typescript-output-lint.js @@ -25,7 +25,6 @@ const unusedViewProps = [ 'onAccessibilityTap', 'onMagicTap', 'accessibilityIgnoresInvertColors', - 'hitSlop', 'removeClippedSubviews', 'collapsable', 'needsOffscreenAlphaCompositing', diff --git a/src/components/Checkbox/CheckboxItem.tsx b/src/components/Checkbox/CheckboxItem.tsx index dd3b5fea21..92ea124e62 100644 --- a/src/components/Checkbox/CheckboxItem.tsx +++ b/src/components/Checkbox/CheckboxItem.tsx @@ -15,7 +15,9 @@ import CheckboxAndroid from './CheckboxAndroid'; import CheckboxIOS from './CheckboxIOS'; import { useInternalTheme } from '../../core/theming'; import type { ThemeProp, MD3TypescaleKey } from '../../types'; -import TouchableRipple from '../TouchableRipple/TouchableRipple'; +import TouchableRipple, { + Props as TouchableRippleProps, +} from '../TouchableRipple/TouchableRipple'; import Text from '../Typography/Text'; export type Props = { @@ -106,6 +108,10 @@ export type Props = { * Left undefined `` will be used. */ mode?: 'android' | 'ios'; + /** + * Sets additional distance outside of element in which a press can be detected. + */ + hitSlop?: TouchableRippleProps['hitSlop']; }; /** @@ -144,6 +150,7 @@ const CheckboxItem = ({ labelMaxFontSizeMultiplier = 1.5, rippleColor, background, + hitSlop, ...props }: Props) => { const theme = useInternalTheme(themeOverrides); @@ -185,6 +192,7 @@ const CheckboxItem = ({ rippleColor={rippleColor} theme={theme} background={background} + hitSlop={hitSlop} > , 'mode'> & { @@ -131,6 +133,10 @@ export type Props = $Omit, 'mode'> & { */ textStyle?: StyleProp; style?: Animated.WithAnimatedValue>; + /** + * Sets additional distance outside of element in which a press can be detected. + */ + hitSlop?: TouchableRippleProps['hitSlop']; /** * @optional */ @@ -202,6 +208,7 @@ const Chip = ({ compact, elevated = false, maxFontSizeMultiplier, + hitSlop, ...rest }: Props) => { const theme = useInternalTheme(themeOverrides); @@ -327,6 +334,7 @@ const Chip = ({ accessibilityState={accessibilityState} testID={testID} theme={theme} + hitSlop={hitSlop} > & { @@ -59,6 +61,10 @@ export type Props = React.ComponentPropsWithRef & { * Color of the ripple effect. */ rippleColor?: ColorValue; + /** + * Sets additional distance outside of element in which a press can be detected. + */ + hitSlop?: TouchableRippleProps['hitSlop']; style?: StyleProp; /** * @optional @@ -98,6 +104,7 @@ const DrawerItem = ({ accessibilityLabel, right, labelMaxFontSizeMultiplier, + hitSlop, ...rest }: Props) => { const theme = useInternalTheme(themeOverrides); @@ -141,6 +148,7 @@ const DrawerItem = ({ accessibilityLabel={accessibilityLabel} rippleColor={customRippleColor || rippleColor} theme={theme} + hitSlop={hitSlop} > diff --git a/src/components/FAB/AnimatedFAB.tsx b/src/components/FAB/AnimatedFAB.tsx index 4cd05fda1d..268b083498 100644 --- a/src/components/FAB/AnimatedFAB.tsx +++ b/src/components/FAB/AnimatedFAB.tsx @@ -28,7 +28,9 @@ import type { $Omit, $RemoveChildren, ThemeProp } from '../../types'; import type { IconSource } from '../Icon'; import Icon from '../Icon'; import Surface from '../Surface'; -import TouchableRipple from '../TouchableRipple/TouchableRipple'; +import TouchableRipple, { + Props as TouchableRippleProps, +} from '../TouchableRipple/TouchableRipple'; import AnimatedText from '../Typography/AnimatedText'; export type AnimatedFABIconMode = 'static' | 'dynamic'; @@ -112,6 +114,10 @@ export type Props = $Omit<$RemoveChildren, 'mode'> & { */ variant?: 'primary' | 'secondary' | 'tertiary' | 'surface'; style?: Animated.WithAnimatedValue>; + /** + * Sets additional distance outside of element in which a press can be detected. + */ + hitSlop?: TouchableRippleProps['hitSlop']; /** * @optional */ @@ -223,6 +229,7 @@ const AnimatedFAB = ({ iconMode = 'dynamic', variant = 'primary', labelMaxFontSizeMultiplier, + hitSlop, ...rest }: Props) => { const theme = useInternalTheme(themeOverrides); @@ -482,6 +489,7 @@ const AnimatedFAB = ({ testID={testID} style={{ borderRadius }} theme={theme} + hitSlop={hitSlop} > { const theme = useInternalTheme(themeOverrides); const [expanded, setExpanded] = React.useState( @@ -260,6 +268,7 @@ const ListAccordion = ({ theme={theme} background={background} borderless + hitSlop={hitSlop} > { const theme = useInternalTheme(themeOverrides); const { titleColor, iconColor, rippleColor } = getMenuItemColor({ @@ -187,6 +194,7 @@ const MenuItem = ({ accessibilityRole="menuitem" accessibilityState={newAccessibilityState} rippleColor={rippleColor} + hitSlop={hitSlop} > {leadingIcon ? ( diff --git a/src/components/RadioButton/RadioButtonItem.tsx b/src/components/RadioButton/RadioButtonItem.tsx index adc1f75813..a68be63e18 100644 --- a/src/components/RadioButton/RadioButtonItem.tsx +++ b/src/components/RadioButton/RadioButtonItem.tsx @@ -17,7 +17,9 @@ import RadioButtonIOS from './RadioButtonIOS'; import { handlePress, isChecked } from './utils'; import { useInternalTheme } from '../../core/theming'; import type { ThemeProp, MD3TypescaleKey } from '../../types'; -import TouchableRipple from '../TouchableRipple/TouchableRipple'; +import TouchableRipple, { + Props as TouchableRippleProps, +} from '../TouchableRipple/TouchableRipple'; import Text from '../Typography/Text'; export type Props = { @@ -112,6 +114,10 @@ export type Props = { * Radio button control position. */ position?: 'leading' | 'trailing'; + /** + * Sets additional distance outside of element in which a press can be detected. + */ + hitSlop?: TouchableRippleProps['hitSlop']; }; /** @@ -156,6 +162,7 @@ const RadioButtonItem = ({ position = 'trailing', labelVariant = 'bodyLarge', labelMaxFontSizeMultiplier, + hitSlop, }: Props) => { const theme = useInternalTheme(themeOverrides); const radioButtonProps = { @@ -219,6 +226,7 @@ const RadioButtonItem = ({ background={background} theme={theme} rippleColor={rippleColor} + hitSlop={hitSlop} > {isLeading && radioButton} diff --git a/src/components/SegmentedButtons/SegmentedButtonItem.tsx b/src/components/SegmentedButtons/SegmentedButtonItem.tsx index d88f2a46f9..92623d249c 100644 --- a/src/components/SegmentedButtons/SegmentedButtonItem.tsx +++ b/src/components/SegmentedButtons/SegmentedButtonItem.tsx @@ -22,7 +22,9 @@ import { import { useInternalTheme } from '../../core/theming'; import type { IconSource } from '../Icon'; import Icon from '../Icon'; -import TouchableRipple from '../TouchableRipple/TouchableRipple'; +import TouchableRipple, { + Props as TouchableRippleProps, +} from '../TouchableRipple/TouchableRipple'; import Text from '../Typography/Text'; export type Props = { @@ -98,6 +100,10 @@ export type Props = { * testID to be used on tests. */ testID?: string; + /** + * Sets additional distance outside of element in which a press can be detected. + */ + hitSlop?: TouchableRippleProps['hitSlop']; /** * @optional */ @@ -123,6 +129,7 @@ const SegmentedButtonItem = ({ density = 'regular', theme: themeOverrides, labelMaxFontSizeMultiplier, + hitSlop, }: Props) => { const theme = useInternalTheme(themeOverrides); @@ -217,6 +224,7 @@ const SegmentedButtonItem = ({ style={rippleStyle} background={background} theme={theme} + hitSlop={hitSlop} > {showCheckedIcon ? (