Opened 7 years ago

Closed 6 years ago

#16569 closed defect (fixed)

[regression] has('touch') apparently reports 'false' on Surface or touch enabled Win8 devices running IE10

Reported by: Paul Christopher Owned by: bill
Priority: high Milestone: 1.8.4
Component: Core Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:

Description

Description

Apparently

has.add("touch", "ontouchstart" in document);

returns 'false' on touch enabled devices running IE 10, see for MS Surface

http://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript/4819886#4819886

and IE10 "modern UI" mode (i.e. the IE10 version run from the start screen not the desktop)

https://github.com/Modernizr/Modernizr/issues/753

Apparently you need to check the msMaxTouchPoints property to get a better guess, see

http://msdn.microsoft.com/en-us/library/ie/hh772144%28v=vs.85%29.aspx

and

http://blog.stevelydford.com/2012/03/detecting-touch-hardware-in-ie-10/

Thus

has.add("touch", "ontouchstart" in document || window.navigator.msMaxTouchPoints);

might fix the issue?

But I have not yet tested this since I don't yet have a touch-enabled Win8 device (Thus I have opened this ticket rather for community testing and validation since it could be a critical point in the near future). If you want to test this: It don't think you need a MS Surface tablet for this but a simple Laptop with a touch screen and Win8 (like the Lenovo ThinkPad X230 Convertible Tablet)?

Additional materials

Change History (12)

comment:1 Changed 7 years ago by Paul Christopher

This official post by Microsoft http://blogs.msdn.com/b/ie/archive/2012/07/12/ie10-user-agent-string-update.aspx also mentions

var hasTouch = navigator.msMaxTouchPoints > 0;

as the way to got to detect touch capabilites.

Very interesting: Even the IE10 user agent string indicates, whether you are running on a touch capable hardware (see blog post above):

IE10 on a machine without touch-capable hardware:

    Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)

IE10 on a machine with touch-capable hardware:

    Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)

(Notice the word "Touch" at the end of the second UA string.)

However that is only intersting for server-side sniffing, I guess. At least Microsoft says for client side detection, feature detection using navigator.msMaxTouchPoints should be used and not UA sniffing.

comment:2 Changed 7 years ago by bill

Milestone: tbd1.8.4
Priority: undecidedhigh

I don't have a Surface either; let's get this into 1.8.4 though. If no one has a Surface device we should just follow Microsoft's advice and add navigator.msMaxTouchPoints > 0 to the test (which is in dojo/has.js).

comment:3 Changed 7 years ago by Paul Christopher

Bill, I think I have found a solution: Visual Studio for Win8 ships together with a "tablet simulator" for Windows store apps, see http://msdn.microsoft.com/library/windows/apps/hh441475.aspx

"ontouchstart" in document 

gives me always false, even in the tablet simulator

"ontouchstart" in document || window.navigator.msMaxTouchPoints

gives me 0 on a normal computer and a number > 0 (in my case: 5) on a touch-enabled device ("the simulator").

comment:4 Changed 7 years ago by Paul Christopher

So maybe the correct fix would use !! to convert the numbers to boolean values?

has.add("touch", "ontouchstart" in document || !!window.navigator.msMaxTouchPoints);

comment:5 Changed 7 years ago by bill

Owner: set to bill
Status: newassigned

Sure, that or window.navigator.msMaxTouchPoints > 0.

comment:6 Changed 7 years ago by bill

Resolution: fixed
Status: assignedclosed

In [30381]:

make has("touch") return true for surface, fixes #16569 on trunk !strict

comment:7 Changed 7 years ago by bill

In [30382]:

make has("touch") return true for surface, fixes #16569 on 1.8 branch !strict

comment:8 Changed 6 years ago by haysmark

Resolution: fixed
Status: closedreopened
Summary: has('touch') apparently reports 'false' on Surface or touch enabled Win8 devices running IE10[regression] has('touch') apparently reports 'false' on Surface or touch enabled Win8 devices running IE10

Starting in [30381] and [30382] in 1.8, it is no longer possible to interact with dijit Buttons with a physical keyboard in IE10 in Windows 8. This does not appear to affect IE10 on Windows 7.

To reproduce:

  1. In Win8 IE10, load http://archive.dojotoolkit.org/nightly/checkout/dijit/tests/form/robot/Button_a11y.html
  2. When the robot tabs to the Edit button and tries to open the menu, nothing happens.

You can also manually reproduce this in test_Button. It appears something is eating onKeyPress whenever you press enter or space. Curiously, pressing shift+enter or shift+space will open the menu.

comment:9 Changed 6 years ago by haysmark

I am running Win8 enterprise in VMWare.

comment:10 Changed 6 years ago by bill

OK, sure, [30381] and [30382] need to be coupled with [30397]. But after [30397] I can use ENTER or SPACE to open the "Edit!" drop down menu in test_Button.html on Windows8 / IE10 running against trunk. I'm not sure why it's not working for you. I tried the code in archive.dojotoolkit.org/nightly too.

Note that #16175 and #16438 are also involved.

comment:11 Changed 6 years ago by bill

PS: what does keyboard have to do with touch? If anything I would expect you to say that mouse is broken.

comment:12 Changed 6 years ago by bill

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.