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-interactions] additional check to avoid middle clicks triggering press #17367
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 7b21a1b:
|
Pretty sure parts of the app rely on middle click triggering pressstart and they can check the value of It might be that no unit tests failed here because we ignore |
@Ambroos can you screenshot what you get with this sandbox, to eliminate all other possible causes for this issue: https://codesandbox.io/s/strange-mcclintock-ttc61 Thinking about it more, it's maybe best to move this logic to the point (if it turns out that |
Sandbox console output after middle clicking, both in Chrome, Firefox and Safari:
This is where I noticed the bug originally. Touchpad-based middle clicks in macOS (triggered by BetterTouchTool) show up in all browsers as button: 1 / buttons: 0. Browsers deal with these middle-clicks correctly, they open |
@Ambroos This is only for BetterTouchTool still? Didn't you mention in our earlier discussion that you were able to repro with a hardware mouse too? Mind trying that again on the sandbox? It would be good to find the cause – browser, system setting, software, hardware etc Maybe |
How do you use the "touchpad + BetterTouchTool tap gesture"? As we should probably record a fixture of the event to unit test this scenario |
BetterTouchTools is pretty popular, probably the most popular magic mouse / trackpad enhancement app for macOS. I'll test again with a hardware mouse later today. |
I've updated the pull request, this approach should be less invasive but still accomplishes the same. |
Tools like BetterTouchTool for macOS trigger middle-clicks with a 'buttons' value that doesn't correspond to the middle-mouse button. To account for this we also inspect the value of 'button'. Close facebook#17367
Tools like BetterTouchTool for macOS trigger middle-clicks with a 'buttons' value that doesn't correspond to the middle-mouse button. To account for this we also inspect the value of 'button'. Close facebook#17367
Middle clicks in Chrome/Firefox on Mac using a touchpad + BetterTouchTool tap gesture trigger a press, causing navigation when this happens on links (in addition to opening links in new tabs).
T57092269 contains more information and videos of fix.
I'm not 100% sure if my edits to the comment make sense.
Looking at the native event for pointer up and down, buttons === 0 and button === 1 when this happens. We covered for buttons === 4 in pointer up, but it looks like these types of middle clicks look slightly different. According to the pointer events spec, button === 1 means it's a middle click, so we added this quick check to avoid triggering press on middle clicks.
I'd be happy to make more changes. Before this the intention was to keep middle clicks around and check for buttons === 4 in pointer up to discard presses there. An alternative to this change could be checking button there instead (as button is still 1 during pointer up). Or, we ignore button === 1 and buttons >= 4 in pointer down and can then remove the 4 check in pointer up completely.