WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Initial focus on search field?

for

From: Tim Harshbarger
Date: Sep 23, 2014 7:00AM


I will offer a dissenting viewpoint.

There is nothing inherently inaccessible about setting the focus to a specific field on a page.

It isn't a problem for screen reader users because screen readers don't even always start reading from the top of the page when focus isn't set to a field. I also think that, if a screen reader has spent much time on the web, they won't think a search field or any other field is likely to be the first item on the page.

It sounds like the problem for keyboard users is not so much setting focus to a field as much as it is ensuring a keyboard user knows where the focus is.

Certainly, it sounds like setting focus to a specific field might sometimes cause additional annoyance to keyboard users, but I'm not sure that is the same as being an accessibility issue. That sounds more like a usability issue. However, at the same time, it sounds like the reason for setting focus to a field is in order to make the user interface more usable.

I would actually tell the developer not to do any special kind of coding. Just set focus to the field and don't hide any focus indicators.

Thanks!
Tim


-----Original Message-----
From: <EMAIL REMOVED> [mailto: <EMAIL REMOVED> ] On Behalf Of Robert Fentress
Sent: Monday, September 22, 2014 2:35 PM
To: WebAIM Discussion List
Subject: [WebAIM] Initial focus on search field?

Hello, all.

Do you have a sense for what is best practice concerning where focus
should initially be set on pages in complex web sites that contain a
prominent global search field on every page?

For our site, the search field appears after an initial set of
navigation links, and at this point, changing the order of the menu
links and the search field in the code isn't feasible. An original
design constraint was that the search field be automatically given
focus upon page load, since usability studies showed that most people
preferred using search to navigate the site.

However, I was concerned that this could present problems for screen
reader users who might not notice the list of links before the search
field. This does seem to be a common pattern on the web though, so I
wonder if screen reader users would expect (and perhaps prefer) this
behavior.

Initially though, I recommended against explicitly setting focus.
Instead, I suggested best practice would be to add, at the start of
the page, a single skip link to the main content, and to create
landmark regions for the main page areas (including role="search" for
the where the search field appears). Screen reader users could then
use landmark navigation to quickly get to the search field.

The developer has gotten pushback though, because of the original
design requirement mandating that focus be set to the initial search
field. He has tried to be creative by not initially setting focus,
instead making it so that, as soon as the user begins typing, focus is
set to the search field. So a tab takes the user to the first link in
the menu on the page, but typing "a search string" automatically moves
the user to the search field and enters the text typed into the field.
This is problematic, though, because some keys are reserved as page
navigation commands by some screen readers, such that typing "b" takes
you to the first button on the page, etc.

At this point, given the constraints we're operating under, I'm
leaning towards just telling him to set focus to the search field,
with the thought that screen reader users may expect this sort of
thing and figure things out, especially given the landmarks provided.
What do you think?

Thanks,
Rob

--
Robert Fentress
Senior Accessibility Solutions Designer
540.231.1255

Technology-enhanced Learning & Online Strategies
Assistive Technologies
1180 Torgersen Hall
620 Drillfield Drive (0434)
Blacksburg, Virginia 24061