Skip to content

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

Merged
necolas merged 1 commit into
react:masterfrom
necolas:react-events/use-buttons-not-button
Aug 21, 2019
Merged

[react-events] Rely on 'buttons' rather than 'button'#16479
necolas merged 1 commit into
react:masterfrom
necolas:react-events/use-buttons-not-button

Conversation

@necolas

@necolas necolas commented Aug 19, 2019

Copy link
Copy Markdown
Contributor

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

sizebot commented Aug 19, 2019

Copy link
Copy Markdown

No significant bundle size changes to report.

Generated by 🚫 dangerJS

Comment thread packages/react-events/src/dom/Press.js
Comment thread packages/react-events/src/dom/Press.js Outdated

@trueadm trueadm left a comment

Copy link
Copy Markdown
Contributor

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).

Comment thread packages/react-events/src/dom/ContextMenu.js Outdated
Comment thread packages/react-events/src/dom/ContextMenu.js Outdated
Comment thread packages/react-events/src/dom/testing-library/domEventSequences.js Outdated
Comment thread packages/react-events/src/dom/testing-library/domEvents.js Outdated
Comment thread packages/react-events/src/dom/testing-library/domEvents.js Outdated
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 react:master Aug 21, 2019
@trueadm

trueadm commented Aug 22, 2019

Copy link
Copy Markdown
Contributor

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

necolas commented Aug 22, 2019

Copy link
Copy Markdown
Contributor Author

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