[whatwg] Modal Dialog Focus

Ian Hickson ian at hixie.ch
Mon Oct 22 11:02:27 PDT 2012

On Mon, 22 Oct 2012, Scott González wrote:
> The dialog.showModal() function defines steps for setting focus. 
> However, if the dialog does not contain any elements with the autofocus 
> attribute, then step 9 says to abort the steps and not set focus. It 
> seems problematic if the dialog is modal and does not have focus. How 
> would a keyboard user interact with the dialog? How would a screen 
> reader know that the dialog has been shown?

This is no different than when the page first loads. If nothing has 
autofocus="", or if no script calls .focus(), then nothing in the page has 
focus. Keyboard users can still use the page (or dialog, in this case), 
because user agents let keyboard users navigate through pages -- hit the 
tab key, and the first thing gets focused. It's as if the <body> holds the 
focus by default.

> I would expect the control element to fall back to the first tab 
> focusable element if no element with autofocus exists. If there is still 
> no control element, I would expect the dialog itself to receive focus.

The first focusable element is the <body> element, effectively.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list