Skip to content

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 15 commits into from
Mar 3, 2025

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Feb 19, 2025

Description

This PR improves the accessibility of the Checkbox and RadioButton components by ensuring a minimum hit target size of 48x48 pixels, following WCAG guidelines. The changes maintain the visual appearance while making the components more accessible for touch interactions.

Changelog

  • Checkbox & RadioButton: Added hitSlop to ensure minimum 48x48 touch target

Additional info

Ticket: MADS-4591

Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@nitzanyiz nitzanyiz self-assigned this Feb 23, 2025
@nitzanyiz
Copy link
Collaborator

Please update the pr description according to our template.

@nitzanyiz
Copy link
Collaborator

Thank you devin. I'll take it from here. Don't respond to anything here anymore.

@@ -257,6 +257,16 @@ class RadioButton extends PureComponent<Props, RadioButtonState> {
);
}

getAccessibleHitSlop() {
const {size = DEFAULT_SIZE} = this.props;
const verticalPadding = Math.max(0, (48 - size) / 2);
Copy link
Collaborator

@Inbal-Tish Inbal-Tish Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only vertical?

Copy link
Collaborator

@nitzanyiz nitzanyiz Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Horizontally the CheckBox takes as much room as it can so it depends on the parent

@@ -252,8 +252,16 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
};
};

getAccessibleHitSlop() {
const {size = DEFAULT_SIZE} = this.props;
const hitTargetPadding = Math.max(0, (48 - size) / 2);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return Math.max(0, (48 - size) / 2);

@Inbal-Tish Inbal-Tish assigned nitzanyiz and unassigned Inbal-Tish Feb 26, 2025
@@ -252,8 +252,16 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
};
};

getAccessibleHitSlop() {
Copy link
Collaborator

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

@nitzanyiz nitzanyiz assigned Inbal-Tish and unassigned nitzanyiz Feb 26, 2025
Copy link
Contributor

@adids1221 adids1221 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nitzanyiz Approved, make sure to fix the Checkbox screen example we talked about.

@nitzanyiz nitzanyiz enabled auto-merge (squash) March 3, 2025 10:14
@nitzanyiz nitzanyiz merged commit 75b4b06 into master Mar 3, 2025
1 check was pending
@nitzanyiz nitzanyiz deleted the devin/1739968065-checkbox-radio-hit-target branch March 3, 2025 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants