w3c / pointerevents

Pointer Events
https://w3c.github.io/pointerevents/
Other
68 stars 34 forks source link

Ambiguity of the value of the `button` property for the `click` event #513

Open rr-codes opened 3 months ago

rr-codes commented 3 months ago

According to the pointer events spec , a pointer event should have a button value of -1 if "Neither buttons nor touch/pen contact changed since last event".

However, this is inconsistent with the behavior of when the click event was a MouseEvent, where the button property would return 0 (for the primary button).

Additionally, it says

The click event should only be fired for the primary pointer button (i.e., when button value is 0, buttonsvalue is 1)

which further seems to contradict the statement that button should be -1 if it hasn't changed.

mustaqahmed commented 1 month ago

Thanks for the catch! The "since last event" part was added way before click was a PointerEvent!!

Possible ways forwards for the spec:

  1. Add a special case for click.button. We already have a special case for click.target after a released pointer, so should be fine?
  2. Change click.button to be -1 because this field is redundant with the auxclick event for non-primary buttons. This would be a breaking change IMO.
mustaqahmed commented 1 month ago

Both Chrome and Firefox show zeroes for click.button and click.buttons.

smaug---- commented 1 month ago

I think we should special case click in the spec. We can't change the behavior. And worth to add a note why such special case.