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

Press events are not dispatched correctly on iOS Chrome/Safari #1061

Closed
hnordt opened this issue Sep 9, 2020 · 8 comments · Fixed by #1613
Closed

Press events are not dispatched correctly on iOS Chrome/Safari #1061

hnordt opened this issue Sep 9, 2020 · 8 comments · Fixed by #1613

Comments

@hnordt
Copy link

hnordt commented Sep 9, 2020

🐛 Bug Report

Press events are not dispatched correctly on iOS.

I've created a Button component with the useButton hook and I noticed press events are not dispatched correctly (but click events are) on iOS Chrome/Safari (I didn't test on Android) if you click in any of the Button edges. It works on desktop though.

🤔 Expected Behavior

useButton / usePress should dispatch press events every time a click event would be dispatched.

😯 Current Behavior

Screencast showing the problem on Chrome iOS: https://d.pr/v/5haGuQ

💻 Code Sample

Codesandbox link: https://codesandbox.io/s/sad-meitner-ssc9k

🌍 Your Environment

Software Version(s)
@react-aria/button 3.2.1
Browser Chrome 85.0.4183.92
Operating System iOS 13.6.1
@hnordt
Copy link
Author

hnordt commented Sep 9, 2020

I was able to reproduce the same issue by using Chrome's desktop built-in mobile emulator:

Screencast: https://d.pr/v/b5dY6k

@devongovett
Copy link
Member

Interesting. Maybe iOS is doing some kind of fuzzy hit testing? Like where you hit within some margin of the button it still fires? But it must not do that for pointer/touch events.

@hnordt
Copy link
Author

hnordt commented Sep 10, 2020

From my understanding when using pointer events for mobile browsers the center of the finger press should be within the button area, otherwise the event will not fire. 🤔

image

@devongovett
Copy link
Member

Yeah that's what I assumed. I guess we'd have to implement our own hit test padding if we wanted to support this. That would likely be a big task since we don't currently implement our own global hit testing and rely on e.g. onPointerDown firing on the button element itself...

@hnordt
Copy link
Author

hnordt commented Sep 10, 2020

@devongovett I’ve showed the issue to @diegohaz and he thinks the issue might be caused by

function isOverTarget(point: EventPoint, target: HTMLElement) {
let rect = target.getBoundingClientRect();
return (point.clientX || 0) >= (rect.left || 0) &&
(point.clientX || 0) <= (rect.right || 0) &&
(point.clientY || 0) >= (rect.top || 0) &&
(point.clientY || 0) <= (rect.bottom || 0);
}

@devongovett
Copy link
Member

Is onPressStart fired? isOverTarget isn't used in onPointerDown

@hnordt
Copy link
Author

hnordt commented Sep 14, 2020

Yes; onClick, onPressChange, onPressStart and onPressEnd are fired but not onPress.

@ktabors
Copy link
Member

ktabors commented Nov 18, 2020

This project is not something we are able to take on at this time. We are happy to work with anyone interested in contributing this improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants