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

The button active effect can prevent it being clicked #3185

Open
mrdaniellewis opened this issue Feb 7, 2024 · 0 comments
Open

The button active effect can prevent it being clicked #3185

mrdaniellewis opened this issue Feb 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mrdaniellewis
Copy link

Summary of problem

Buttons have an :active css property of transform: translate(0, 2px).

This causes the top of the button to move down when active creating a skeuomorphorphic effect of the button being pressed down.

A button click event occurs on a pointer up, and only if the pointer is still over the target.

Unfortunately this means if you click the button in the top 2px, the button moves down and the pointer is no longer over the button on pointer up. The result is no click action

Steps to replicate

In your browser console find a button in the design system (eg on https://citizens-advice-design-system.netlify.app/components/button/)

View the button in the inspector panel, and run $0.addEventListener('click', () => console.log('clicked')) to add a click event to it.

Click in the middle of the button and ensure the console logs "clicked".

Now click in the top two pixels of the button. You may want to zoom in so this 2px target area is larger. Notice the pointer changes to a hand to show it as clickable.

Expected behaviour

the console logs "clicked"

Actual behaviour

the console logs nothing

Context

https://citizens-advice-design-system.netlify.app/components/button/
Confirmed on Firefox, Chrome and Safari

@mrdaniellewis mrdaniellewis added the bug Something isn't working label Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant