Skip to content
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

Prevent accidental miss-clicks outside multi-select checkboxes #1704

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

acelaya
Copy link
Contributor

@acelaya acelaya commented Sep 9, 2024

This is an alternative PR to #1700

We have experienced (and more people has reported) that it is easy to miss-click outside a checkbox on a MultiSelect option. This is problematic, because clicking on a checkbox appends/removes the item to the selection, but clicking outside of it is captured as a click on the main option's body, causing the whole selection to be replaced with just that option.

multi-select-current-2024-09-06_11.00.31.mp4

This PR changes that behavior, so that clicking on "the surroundings" of the checkbox behaves as clicking the checkbox itself.

"The surroundings" in this case means anywhere inside the right side of the option, matching the option's padding. That way the checkbox is always clicked if you click anywhere on the "right" side of an option.

This shows how it behaves with these changes:

multi-select-fixed-2024-09-06_11.13.12.mp4

Note

This PR is easier to review ignoring whitespaces

Test steps

  1. Check out this PR
  2. Start dev server via make dev.
  3. Go to http://localhost:4001/input-select
  4. Scroll to the very bottom, where the multi-select is demoed, and verify you can click close to the checkbox, anywhere in the option, and it still acts as if the checkbox was clicked.

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (703add7) to head (d0f25ca).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1704   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           66        66           
  Lines         1115      1121    +6     
  Branches       435       439    +4     
=========================================
+ Hits          1115      1121    +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@acelaya
Copy link
Contributor Author

acelaya commented Sep 9, 2024

@marcospri a similar PR, #1700, was already reviewed by Rob.

This is almost the same, but with a slightly less hacky approach, so you can do a high level review. No need to go too deep in the details.

@acelaya acelaya marked this pull request as ready for review September 9, 2024 11:32
Copy link
Member

@marcospri marcospri left a comment

Choose a reason for hiding this comment

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

This looks very sensible 👍

@acelaya acelaya merged commit 4011deb into main Sep 10, 2024
4 checks passed
@acelaya acelaya deleted the multi-select-checkbox-miss-click branch September 10, 2024 09:59
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