Autofocus the search field on the index page. #175

Closed
wants to merge 2 commits into
from

3 participants

@jfirebaugh
OpenStreetMap on GitHub member

Autofocus can be annoying for power users or people with special needs. If we're going to do this, please use the HTML5 autofocus attribute instead.

@ppawel

What is the benefit of using the autofocus attribute in this case? What about browsers that do not support HTML5?

@jfirebaugh
OpenStreetMap on GitHub member

Dive Into HTML5 explains the problems with script-based autofocus and provides a polyfill:

http://diveintohtml5.info/forms.html#autofocus

@tomhughes
OpenStreetMap on GitHub member

Which is in fact the same as the original patch posted on the trac ticket, which I rejected in large part because of the direct use of getElementById which I didn't think was fully portable.

I also hadn't understood, and the author didn't explain, why using the autofocus attribute was a good idea even if you were still going to do it in javascript as well.

@ppawel

Done, now it uses the 'autofocus' attribute with JS as fallback.

@jfirebaugh
OpenStreetMap on GitHub member

@tomhughes The polyfill script focuses the input only if the autofocus attribute isn't supported. If it is supported, it does nothing, thus preserving the benefits of that approach.

@tomhughes
OpenStreetMap on GitHub member

Yes I know that, just saying I didn't realise the benefit - ie that there was a real gain in using the attribute where it is available.

@tomhughes
OpenStreetMap on GitHub member

Merged.

@tomhughes tomhughes closed this Dec 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment