Open jstanley0 opened 4 years ago
you can use:
return e.button !== undefined ? e.button : e.which;
With this modification, if e.button is available, it will be returned. Otherwise, if e.button is undefined, it will fall back to e.which. This way, you ensure consistent behavior for determining the primary button regardless of the event system being used.
I also edited this in the code and requested a pull request
This line of code is incorrect:
return null == e.which ? e.button : e.which;
because
which
returns 1 to mean the primary button, andbutton
returns 0 to mean the same thing.When calling
clickHandler
from a ReactonClick
, a synthetic event is supplied which implementsbutton
but notwhich
. As a result,_which
returns 0 and the event handler skips the event because it was expecting 1.