From de3f49fe57aa71e43dc536a1758c77bb54addfec Mon Sep 17 00:00:00 2001 From: abretonc7s Date: Wed, 2 Oct 2024 09:59:07 +0800 Subject: [PATCH] fix: invalid touchable area on mobile browser --- src/components/FAB/FABGroup.tsx | 180 ++++++++++++++++---------------- 1 file changed, 91 insertions(+), 89 deletions(-) diff --git a/src/components/FAB/FABGroup.tsx b/src/components/FAB/FABGroup.tsx index af1e85c4cb..6c193c58db 100644 --- a/src/components/FAB/FABGroup.tsx +++ b/src/components/FAB/FABGroup.tsx @@ -358,100 +358,102 @@ const FABGroup = ({ ]} /> - - {actions.map((it, i) => { - const labelTextStyle = { - color: it.labelTextColor ?? labelColor, - ...(isV3 ? theme.fonts.titleMedium : {}), - }; - const marginHorizontal = - typeof it.size === 'undefined' || it.size === 'small' ? 24 : 16; - const accessibilityLabel = - typeof it.accessibilityLabel !== 'undefined' - ? it.accessibilityLabel - : it.label; - const size = typeof it.size !== 'undefined' ? it.size : 'small'; + {open && ( + + {actions.map((it, i) => { + const labelTextStyle = { + color: it.labelTextColor ?? labelColor, + ...(isV3 ? theme.fonts.titleMedium : {}), + }; + const marginHorizontal = + typeof it.size === 'undefined' || it.size === 'small' ? 24 : 16; + const accessibilityLabel = + typeof it.accessibilityLabel !== 'undefined' + ? it.accessibilityLabel + : it.label; + const size = typeof it.size !== 'undefined' ? it.size : 'small'; - return ( - - {it.label && ( - - { - it.onPress(e); - close(); - }} - accessibilityHint={it.accessibilityHint} - importantForAccessibility="no-hide-descendants" - accessibilityElementsHidden={true} - style={[ - styles.containerStyle, - { - transform: [ - isV3 - ? { translateY: labelTranslations[i] } - : { scale: scales[i] }, - ], - opacity: opacities[i], - }, - isV3 && styles.v3ContainerStyle, - it.containerStyle, - ]} - > - - {it.label} - - - - )} - { - it.onPress(e); - close(); - }} - importantForAccessibility="no-hide-descendants" - testID={it.testID} - visible={open} - rippleColor={it.rippleColor} - /> - - ); - })} - + pointerEvents={open ? 'box-none' : 'none'} + accessibilityRole="button" + importantForAccessibility="yes" + accessible={true} + accessibilityLabel={accessibilityLabel} + > + {it.label && ( + + { + it.onPress(e); + close(); + }} + accessibilityHint={it.accessibilityHint} + importantForAccessibility="no-hide-descendants" + accessibilityElementsHidden={true} + style={[ + styles.containerStyle, + { + transform: [ + isV3 + ? { translateY: labelTranslations[i] } + : { scale: scales[i] }, + ], + opacity: opacities[i], + }, + isV3 && styles.v3ContainerStyle, + it.containerStyle, + ]} + > + + {it.label} + + + + )} + { + it.onPress(e); + close(); + }} + importantForAccessibility="no-hide-descendants" + testID={it.testID} + visible={open} + rippleColor={it.rippleColor} + /> + + ); + })} + + )} { onPress?.(e);