-
Notifications
You must be signed in to change notification settings - Fork 734
feat(checkbox/radioButton): ensure minimum 48x48 hit target for better accessibility #3518
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
10c3c97
feat(checkbox/radioButton): ensure minimum 48x48 hit target for bette…
devin-ai-integration[bot] 18aca35
refactor: destructure props at top of render functions
devin-ai-integration[bot] 29c3852
fix: use destructured iconOnRight prop
devin-ai-integration[bot] 9ce4651
refactor(checkbox/radioButton): move hitSlop calculation to dedicated…
devin-ai-integration[bot] e3f67db
fix(radioButton): revert iconOnRight prop destructuring
devin-ai-integration[bot] 14921a6
fix(radioButton): revert iconOnRight prop destructuring changes
devin-ai-integration[bot] e5e72ff
fix(radioButton): only apply hitSlop to top and bottom
devin-ai-integration[bot] c7d9235
fix(radioButton): remove unused horizontalPadding variable
devin-ai-integration[bot] 84eb5b9
refactor(checkbox): simplify hitSlop padding variable
devin-ai-integration[bot] d73d48e
Update src/components/checkbox/index.tsx
nitzanyiz f8133df
fix(checkbox): update getAccessibleHitSlop to accept size parameter
nitzanyiz 2a1a3cf
Changed getAccessibleHitSlop to get size as argument
nitzanyiz 3b19c50
Added gap to RadioGroup example to fit new hit target
nitzanyiz 1413792
Merge remote-tracking branch 'origin' into devin/1739968065-checkbox-…
nitzanyiz 4d29687
fix(checkbox): increase right margin for improved layout
nitzanyiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -257,8 +257,21 @@ class RadioButton extends PureComponent<Props, RadioButtonState> { | |
); | ||
} | ||
|
||
getAccessibleHitSlop() { | ||
const {size = DEFAULT_SIZE} = this.props; | ||
const verticalPadding = Math.max(0, (48 - size) / 2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why only vertical? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Horizontally the |
||
const horizontalPadding = verticalPadding; | ||
|
||
return { | ||
top: verticalPadding, | ||
bottom: verticalPadding, | ||
left: horizontalPadding, | ||
right: horizontalPadding | ||
nitzanyiz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
} | ||
|
||
render() { | ||
const {onPress, onValueChange, containerStyle, contentOnLeft, ...others} = this.props; | ||
const {onPress, onValueChange, containerStyle, contentOnLeft, iconOnRight, ...others} = this.props; | ||
nitzanyiz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const Container = onPress || onValueChange ? TouchableOpacity : View; | ||
|
||
return ( | ||
|
@@ -271,10 +284,11 @@ class RadioButton extends PureComponent<Props, RadioButtonState> { | |
style={containerStyle} | ||
onPress={this.onPress} | ||
{...this.getAccessibilityProps()} | ||
hitSlop={Container === TouchableOpacity ? this.getAccessibleHitSlop() : undefined} | ||
> | ||
{!contentOnLeft && this.renderButton()} | ||
{this.props.iconOnRight ? this.renderLabel() : this.renderIcon()} | ||
{this.props.iconOnRight ? this.renderIcon() : this.renderLabel()} | ||
{iconOnRight ? this.renderLabel() : this.renderIcon()} | ||
{iconOnRight ? this.renderIcon() : this.renderLabel()} | ||
nitzanyiz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{contentOnLeft && this.renderButton()} | ||
</Container> | ||
); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I would make it a pure function that gets the size and returns the hitslop