Skip to content

feat(button & stepper): ensure minimum 48x48 hit target for better accessibility #3522

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 8 commits into from
Feb 27, 2025

Conversation

nitzanyiz
Copy link
Collaborator

@nitzanyiz nitzanyiz commented Feb 19, 2025

Description

Added hit slop to the button component based on its size.
This pr fixes the stepper as well.

Changelog

Button - Fixed hit target to be at least of 48x48.
Stepper - Fixed hit target to be at least of 48x48.

Additional info

MADS-4591

@nitzanyiz nitzanyiz changed the title Draft: feat/button-accesibility-hit-target feat(button): ensure minimum 48x48 hit target for better accessibility Feb 19, 2025
@nitzanyiz nitzanyiz self-assigned this Feb 23, 2025
@nitzanyiz nitzanyiz requested a review from ethanshar February 23, 2025 13:03
@nitzanyiz nitzanyiz removed their assignment Feb 23, 2025
@nitzanyiz nitzanyiz marked this pull request as ready for review February 23, 2025 13:03
@nitzanyiz nitzanyiz changed the title feat(button): ensure minimum 48x48 hit target for better accessibility feat(button / stepper): ensure minimum 48x48 hit target for better accessibility Feb 23, 2025
@nitzanyiz nitzanyiz changed the title feat(button / stepper): ensure minimum 48x48 hit target for better accessibility feat(button & stepper): ensure minimum 48x48 hit target for better accessibility Feb 23, 2025
Comment on lines 354 to 355
const isWidthDefined = containerStyle.width !== undefined || containerStyle.minWidth !== undefined;
const width = containerStyle.width || containerStyle.minWidth || 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we combine both
I think isWidthDefined is redundant, you check run checks on the width (if it's zero it's undefined)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed

Copy link
Collaborator Author

@nitzanyiz nitzanyiz Feb 24, 2025

Choose a reason for hiding this comment

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

I found why I added this. There are times (when the button is round) when the width and height is undefined but there is padding this way the button is not just the padding because of the text inside of it and we will add extra hitslop for nothing. Instead of just the 10 we decided to add by default.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because the width will not be zero in this case (it will have the padding)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ethanshar ping

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As we've talked I'm reverting the changes I did so we make the isWidthDefined check. I'll change it to isWidthSet as well. I think its more readable. wdyt?

@ethanshar ethanshar assigned nitzanyiz and unassigned ethanshar Feb 24, 2025
@nitzanyiz nitzanyiz assigned ethanshar and unassigned nitzanyiz Feb 24, 2025
@ethanshar ethanshar merged commit 92259ba into master Feb 27, 2025
1 check passed
@ethanshar ethanshar deleted the feat/button-accesibility-hit-target branch February 27, 2025 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants