Fix avi button hitslops (#6662)
* Remove web hack from non-web file * Remove hitSlop on the wrong Pressable It is not doing anything useful. * Extend avi column to prevent hit rect clipping You can't click outside the parent on Android. * Bump pressed opacity to .8 * Slightly reduce avi button hitslops * Asymmetric hit slop
This commit is contained in:
@@ -95,7 +95,14 @@ export function AviFollowButton({
|
|||||||
<NativeDropdown items={items}>
|
<NativeDropdown items={items}>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
{width: 30, height: 30},
|
{
|
||||||
|
// An asymmetric hit slop
|
||||||
|
// to prioritize bottom right taps.
|
||||||
|
paddingTop: 2,
|
||||||
|
paddingLeft: 2,
|
||||||
|
paddingBottom: 6,
|
||||||
|
paddingRight: 6,
|
||||||
|
},
|
||||||
a.align_center,
|
a.align_center,
|
||||||
a.justify_center,
|
a.justify_center,
|
||||||
a.rounded_full,
|
a.rounded_full,
|
||||||
|
|||||||
@@ -618,10 +618,10 @@ const styles = StyleSheet.create({
|
|||||||
layout: {
|
layout: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
marginTop: 1,
|
marginTop: 1,
|
||||||
gap: 10,
|
|
||||||
},
|
},
|
||||||
layoutAvi: {
|
layoutAvi: {
|
||||||
paddingLeft: 8,
|
paddingLeft: 8,
|
||||||
|
paddingRight: 10,
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
zIndex: 999,
|
zIndex: 999,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,10 +5,9 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
|||||||
import * as DropdownMenu from 'zeego/dropdown-menu'
|
import * as DropdownMenu from 'zeego/dropdown-menu'
|
||||||
import {MenuItemCommonProps} from 'zeego/lib/typescript/menu'
|
import {MenuItemCommonProps} from 'zeego/lib/typescript/menu'
|
||||||
|
|
||||||
import {HITSLOP_10} from '#/lib/constants'
|
|
||||||
import {usePalette} from '#/lib/hooks/usePalette'
|
import {usePalette} from '#/lib/hooks/usePalette'
|
||||||
import {useTheme} from '#/lib/ThemeContext'
|
import {useTheme} from '#/lib/ThemeContext'
|
||||||
import {isIOS, isWeb} from '#/platform/detection'
|
import {isIOS} from '#/platform/detection'
|
||||||
import {Portal} from '#/components/Portal'
|
import {Portal} from '#/components/Portal'
|
||||||
|
|
||||||
// Custom Dropdown Menu Components
|
// Custom Dropdown Menu Components
|
||||||
@@ -30,31 +29,18 @@ export const DropdownMenuTrigger = DropdownMenu.create(
|
|||||||
(props: TriggerProps) => {
|
(props: TriggerProps) => {
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
const defaultCtrlColor = theme.palette.default.postCtrl
|
const defaultCtrlColor = theme.palette.default.postCtrl
|
||||||
const ref = React.useRef<View>(null)
|
|
||||||
|
|
||||||
// HACK
|
|
||||||
// fire a click event on the keyboard press to trigger the dropdown
|
|
||||||
// -prf
|
|
||||||
const onPress = isWeb
|
|
||||||
? (evt: any) => {
|
|
||||||
if (evt instanceof KeyboardEvent) {
|
|
||||||
// @ts-ignore web only -prf
|
|
||||||
ref.current?.click()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: undefined
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
// This Pressable doesn't actually do anything other than
|
||||||
|
// provide the "pressed state" visual feedback.
|
||||||
<Pressable
|
<Pressable
|
||||||
testID={props.testID}
|
testID={props.testID}
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
accessibilityLabel={props.accessibilityLabel}
|
accessibilityLabel={props.accessibilityLabel}
|
||||||
accessibilityHint={props.accessibilityHint}
|
accessibilityHint={props.accessibilityHint}
|
||||||
style={({pressed}) => [{opacity: pressed ? 0.5 : 1}]}
|
style={({pressed}) => [{opacity: pressed ? 0.8 : 1}]}>
|
||||||
hitSlop={HITSLOP_10}
|
|
||||||
onPress={onPress}>
|
|
||||||
<DropdownMenu.Trigger action="press">
|
<DropdownMenu.Trigger action="press">
|
||||||
<View ref={ref}>
|
<View>
|
||||||
{props.children ? (
|
{props.children ? (
|
||||||
props.children
|
props.children
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in New Issue
Block a user