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

[react-events] Rely on 'buttons' rather than 'button' #16479

Merged

Conversation

necolas
Copy link
Contributor

@necolas necolas commented Aug 19, 2019

The semantics of 'button' on events differs between PointerEvent and
MouseEvent, whereas they are the same for 'buttons'. Furthermore, 'buttons'
allows developers to determine when multiple buttons are pressed as the same
time.

https://w3c.github.io/pointerevents/#the-button-property

@sizebot
Copy link

sizebot commented Aug 19, 2019

No significant bundle size changes to report.

Generated by 🚫 dangerJS

Copy link
Contributor

@trueadm trueadm left a comment

Choose a reason for hiding this comment

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

I'm a little confused as to why this is buttons = 1 | 4 rather than 1 | 2 | 4?

0 MUST indicate no button is currently active.
1 MUST indicate the primary button of the device (in general, the left button or the only button on single-button devices, used to activate a user interface control or select text).
2 MUST indicate the secondary button (in general, the right button, often used to display a context menu), if present.
4 MUST indicate the auxiliary button (in general, the middle button, often combined with a mouse wheel).

The semantics of 'button' on events differs between PointerEvent and
MouseEvent, whereas they are the same for 'buttons'. Furthermore, 'buttons'
allows developers to determine when multiple buttons are pressed as the same
time.

https://w3c.github.io/pointerevents/#the-button-property
@necolas necolas force-pushed the react-events/use-buttons-not-button branch from 006137a to 25eb83f Compare August 20, 2019 00:53
@necolas necolas merged commit 2559111 into facebook:master Aug 21, 2019
@trueadm
Copy link
Contributor

trueadm commented Aug 22, 2019

Seems like there's maybe a case we haven't handled here. Middle mouse buttons are reported with event.button of 1 but the event.buttons value is 0.

@necolas
Copy link
Contributor Author

necolas commented Aug 22, 2019

Reported as 0 where?

@necolas necolas deleted the react-events/use-buttons-not-button branch December 20, 2019 15:36
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.

4 participants