-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Change touch device detection method #5919
base: main
Are you sure you want to change the base?
Conversation
Thank you for pointing out this problem, was not aware! To clarify, does the current implementation work whenever you plug in a mouse to your Android, or does neither solution work for that? |
The current implementation doesn't work for that either no. And with this method the "primary input mechanism" on a phone seems to always be touch no matter what as neither |
Another thought I had was to maybe filter for But in my testing on Android even when using a physical mouse |
Small update, I've come across a few people who also encounter this issue because they have a display drawing tablet connected to their pc, which is also recognized as a touch screen. I imagine there's a sizable group of artists on the platform also not seeing a volume slider or hover cards because of this. |
If you read through https://css-tricks.com/interaction-media-features-and-their-potential-for-incorrect-assumptions/, does the approach still hold up? (I haven't) |
Thanks for the article! Great read. Whether it holds up depends on how you look at it I suppose. Even with all the pitfalls I still think that checking for
I did already look at https://patrickhlauke.github.io/touch/pointer-hover-any-pointer-any-hover/results too, which is also mentioned in the article, to help determine what to use here (though it's slightly out of date). It would probably be a good idea to supplement this using input events like https://github.com/ten1seven/what-input to determine the currently used input method aside from the primary one (package mentioned in the article, no idea if others exist for this, I haven't been able to find any). But that's quite a bit more involved of course. And you still run into issues like the fact that hover/enter/over events aren't really supported on Android web for example (in my testing at least, they just fire on click, even with a physical mouse). It might also be a good idea to just give the user the option to switch manually as well (which the article also suggests). Especially when taking assistive technologies and browser bugs/differences into account. There doesn't seem to be a perfectly accurate way of determining this stuff. Switching to |
Using
navigator.maxTouchPoints
to check whether a device is a "touch device" also matches laptops with touch screen support. Checking forpointer: coarse
instead should only detect whether the primary input mechanism is touch (e.g. smartphones and tablets but not laptops with touch screens).It's not perfect though. No combination of
(any-)pointer
and(any-)hover
seems to work for detecting when I plug a physical mouse into my Android phone for example. Might have to rely on thetouchstart
event for that.Checking
pointer: coarse
is better than the current method at least as it does properly distinguish between mobile/tablet and pc, which the current method doesn't.Resolves #5856 (hover cards and video volume slider not showing up), resolves #5859 (enter not sending chat messages)