-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: support auxiliary clicks #45
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thank you for your contribution, @marcusforsberg! I will review this PR sometime this week. |
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.
Thanks again for your contribution. I did a quick test and it seems fine to remove the event.button
guard but please do let me know if there was a specific reason you implemented it.
if (event.button !== 1) { | ||
return; | ||
} |
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.
My concern is that this is too specific for a library... Is this guard really necessary? Is there a downside to letting all aux events pass through?
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.
This is so that the handler specifically only handles middle mouse clicks. I believe if we removed it, it would start firing on the other mouse buttons as well (right click, browser back, browser forward), as per this list: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button#value (since the auxclick
event fires for all non-primary mouse buttons).
That said I honestly only learned about the existence of auxclick
when I set out to implement this, so I am in no way an expert! 😄
Hi Tim,
A colleague of mine noticed that the card component (which we're using heavily in our projects, thanks again!) doesn't support auxiliary clicks, i.e clicking with the middle mouse button or scroll wheel to open in a new tab.
This PR fixes this using
onAuxClick
.I added this to the existing
useRedundantClick
hook; I guess the alternative would be to create a separete hook, but that hook would need to be passed thetargetRef
fromuseRedundantClick
in order to work, so I opted for the simpler route of doing both events in the same hook. Let me know if you'd prefer the other option and I can adjust this PR accordingly. 😊