mabusi / go-tour

Automatically exported from code.google.com/p/go-tour
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Keyboard appearing on mobile devices #42

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Discovered this whilst browsing the Go Tour on my iPad, when new pages of the 
tour are display (pressing previous/next) the software keyboard is displayed 
every time. I am unsure whether this is the intended behavior of the Go Tour, 
but regardless, it was very frustrating on a mobile device.

This is being caused by line 185 of /static/tour.js 
(https://code.google.com/p/go-tour/source/browse/static/tour.js#185):

181        } else {
182                $('#workspace').show();
183                $output.empty();
184                editor.setValue(load(i) || $s.find('pre.source').text());
185                editor.focus();
186        }

I propose that setting focus of the code area should only happen when the 
client is known to have a hardware keyboard. This may be a rather big ask, so 
instead, don't set focus on a mobile device.

Original issue reported on code.google.com by nadineng...@gmail.com on 16 Sep 2012 at 7:57

GoogleCodeExporter commented 8 years ago
Any idea how to reliably detect when we're on a mobile device?

Original comment by a...@golang.org on 17 Sep 2012 at 4:56

GoogleCodeExporter commented 8 years ago
A quick and simple way as discused here http://stackoverflow.com/a/3540295 is 
to check for keywords in the user agent.

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows 
Phone/i.test(navigator.userAgent) == false) {
        editor.focus();
}

N.B. I have included Windows Phone in there too, seperate from the SO answer.

Projects like http://detectmobilebrowsers.com/ offer more robust solutions for 
multiple platforms, they appear to have jQuery script, so that should fit right 
in with the Go Tour already.

Original comment by nadineng...@gmail.com on 18 Sep 2012 at 11:32

GoogleCodeExporter commented 8 years ago
Removing the call to editor.focus() completely (for all platforms) is another 
option.

It's simple, keeps the experience consistent across browsers and isn't a huge 
loss.

Choosing to edit the code requires enough activity that an extra mouse click 
won't be a burden.

Original comment by josephmd...@gmail.com on 19 Mar 2013 at 6:46