is-touch-device icon indicating copy to clipboard operation
is-touch-device copied to clipboard

On EDGE browser the function return "true"

Open arshKhachatryan opened this issue 6 years ago • 17 comments

Hi, the module return TRUE for EDGE browser, which in its turn creates bug in airbnb/react-dates. This issue exist even in https://www.airbnb.com/ when browsing with Edge. https://www.screencast.com/t/bDGA6Czw

arshKhachatryan avatar Mar 01 '19 15:03 arshKhachatryan

Many windows laptops these days have touch screens. Are you using Edge on a device that has a touch screen?

Also, I'm unable to view your video because it requires Flash. Can you share it in some other way?

lencioni avatar Mar 01 '19 18:03 lencioni

Actually I came here because of airbnb/react-dates. I was using the module, and then found out that it is not working correctly in Edge browser on Windows 10. You can go to https://www.airbnb.com/ and just pick a date range, but first try it on Chrome/Mozilla/IE11 then on Edge to compare them. And here is the related issue on react-dates https://github.com/airbnb/react-dates/issues/697. Thanks.

arshKhachatryan avatar Mar 01 '19 18:03 arshKhachatryan

@arshKhachatryan can you confirm that your device doesn't actually have a touch screen?

ljharb avatar Mar 06 '19 06:03 ljharb

Yes, 100% , I am using Lenovo T470, if my laptop has had touch screen, I would have the same problem in other browsers.

arshKhachatryan avatar Mar 06 '19 11:03 arshKhachatryan

@arshKhachatryan I'm unable to reproduce this; can you open up your browser console and provide the results for this code:

[
  'ontouchstart' in window,
  window.DocumentTouch,
  document instanceof window.DocumentTouch,
  navigator.maxTouchPoints,
  navigator.msMaxTouchPoints
]

Thanks!

ljharb avatar Mar 07 '19 07:03 ljharb

const chrome = {
            'ontouchstart' in window: false,
            window.DocumentTouch: undefined,
            document instanceof window.DocumentTouch: Uncaught TypeError: Right-hand side of 'instanceof' is not an object,
            navigator.maxTouchPoints: 0,
            navigator.msMaxTouchPoints: undefined
        }
const Edge = {
            'ontouchstart' in window: false,
            window.DocumentTouch: undefined,
            document instanceof window.DocumentTouch: Invalid operand to 'instanceof': Function expected,
            navigator.maxTouchPoints: 2,
            navigator.msMaxTouchPoints: undefined
        }
const EdgeOnPC = {
           /* the rest values are the same*/
            navigator.maxTouchPoints: 0
        }

@ljharb I made a little research, and it turned out, that on pc, navigator.maxTouchPoints returns 0, though in my laptop is returns 2, but on laptop my other browsers return 0 for navigator.maxTouchPoints. I think depending on laptop model, browsers may give different values which I assume is related to the touch-pads that specific laptop, notebook uses. If navigator.maxTouchPoints equals 2 for not all touch devices, only for those that are not not touch devices like my laptop, I think navigator.maxTouchPoints: 2 case can be put in the code as an exception.

arshKhachatryan avatar Mar 07 '19 08:03 arshKhachatryan

That seems premature; given that the spec says that any touchPoints value > 1 indicates touch support. Is there a chance that your laptop's trackpad has multitouch?

ljharb avatar Mar 07 '19 08:03 ljharb

(Also, what's the value of window.PointerEvent in those browsers?)

ljharb avatar Mar 07 '19 08:03 ljharb

I'm particularly looking at https://patrickhlauke.github.io/touch/touchscreen-detection/ as an alternative.

ljharb avatar Mar 07 '19 08:03 ljharb

Yes my laptop's trackpad has multitouch. Is there any specific value you want from this window.PointerEvent?

arshKhachatryan avatar Mar 07 '19 08:03 arshKhachatryan

And unfortunately this https://patrickhlauke.github.io/touch/touchscreen-detection/ also detected touchscreen in my EDGE

arshKhachatryan avatar Mar 07 '19 08:03 arshKhachatryan

If it's got multitouch, it's a touch device - I'm not sure there's an issue here (altho it's surprising that Chrome doesn't report it as one)

ljharb avatar Mar 07 '19 08:03 ljharb

The confusion from my part is that only the EDGE treats it as an touch device, others do not,

arshKhachatryan avatar Mar 07 '19 08:03 arshKhachatryan

Right - i'm not clear on whether that's an Edge bug, or a bug in those other browsers.

ljharb avatar Mar 08 '19 07:03 ljharb

I had the same problem, and we had to fallback to Modernizr's version:

https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js

Stanko avatar May 13 '19 14:05 Stanko

A bit late to the party but there is a confirmed bug in Edge. Not sure if this was the current Edge version when the issue was initially raised.

https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/20417074/

maxwondercorn avatar Jul 15 '19 14:07 maxwondercorn

Just updated MS Edge to latest version and the bug is gone. Edge v79+ uses chromium-based engine which works as expected. I am using this: const supportsTouch = 'ontouchstart' in window || window.navigator.maxTouchPoints > 0 || window.navigator.msMaxTouchPoints > 0;

andriusign avatar Apr 23 '20 08:04 andriusign