-
Notifications
You must be signed in to change notification settings - Fork 735
feat(avatar): ensure minimum 48x48 hit target for better accessibility #3521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Please remove these tests here |
Also remove this file: |
Co-Authored-By: [email protected] <[email protected]>
Please update the pr description according to our template. |
Change the change log to be more concise and don't expose implementation details. Explain the general idea. |
Co-Authored-By: [email protected] <[email protected]>
src/components/avatar/index.tsx
Outdated
@@ -187,6 +187,17 @@ const Avatar = forwardRef<any, AvatarProps>((props: AvatarProps, ref: React.Forw | |||
onPress, | |||
children | |||
} = themeProps; | |||
|
|||
const accessibleHitSlop = useMemo(() => { | |||
const hitTargetPadding = Math.max(0, (48 - size) / 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hitSlop can be a number by type.
react-native type: Rect or number, currently we are using Rect.
Let's use number instead since all the Rect values are identical.
Also when using number we don't need to memoize the object we can pass the Math.max to the hitSlop values itself
I've simplified the hitSlop implementation by:
The changes have been pushed in commit 6f27e01. |
Done! I've simplified the implementation by:
Changes are in commit 6f27e01. |
Done! I've simplified the implementation by:
Changes are in commit 6f27e01. |
The build is failing, take a look at the test please. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved (after changing the hitSlop to be a number).
Description
Improves Avatar component accessibility by ensuring a minimum touch target size while maintaining performance through memoization.
Changelog
Avatar: Added minimum touch target size with performance optimizations
Additional info
Following WCAG guidelines for touch target size (https://www.w3.org/WAI/WCAG21/Understanding/target-size.html)