Skip to content

Commit 6f27e01

Browse files
refactor(avatar): simplify hitSlop using number type
Co-Authored-By: nitzany@wix.com <nitzany@wix.com>
1 parent 5113b56 commit 6f27e01

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/components/avatar/index.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,7 @@ const Avatar = forwardRef<any, AvatarProps>((props: AvatarProps, ref: React.Forw
188188
children
189189
} = themeProps;
190190

191-
const accessibleHitSlop = useMemo(() => {
192-
const hitTargetPadding = Math.max(0, (48 - size) / 2);
193-
return {
194-
top: hitTargetPadding,
195-
bottom: hitTargetPadding,
196-
left: hitTargetPadding,
197-
right: hitTargetPadding
198-
};
199-
}, [size]);
200-
191+
const hitTargetPadding = Math.max(0, (48 - size) / 2);
201192
const {size: _badgeSize, borderWidth: badgeBorderWidth = 0} = badgeProps;
202193
const badgeSize = _badgeSize || DEFAULT_BADGE_SIZE;
203194

@@ -357,7 +348,7 @@ const Avatar = forwardRef<any, AvatarProps>((props: AvatarProps, ref: React.Forw
357348
accessible={!_.isUndefined(onPress)}
358349
accessibilityLabel={'Avatar'}
359350
accessibilityRole={onPress ? 'button' : 'image'}
360-
hitSlop={onPress ? accessibleHitSlop : undefined}
351+
hitSlop={onPress ? hitTargetPadding : undefined}
361352
{...accessibilityProps}
362353
>
363354
<View testID={`${testID}.container`} style={textContainerStyle}>

0 commit comments

Comments
 (0)