> I can't name a single browser that automatically scrolls to and focuses a link at the bottom of several pages of content simply because it was the first tabbable/focusable element within the content. That's not the case we're talking about. Open this in any browser that supports
This issue is not about the autofocus attribute. This issue is about dialogs containing content like this:
Open that in any browser and you'll see that it does not focus the link at the bottom automatically. It displays the first page of text as expected and the user can still tab to the link at the bottom.
> You should review section 7.4. You should review the dialog element: http://www.w3.org/html/wg/drafts/html/master/interactive-elements.html#the-dialog-element > When the dialog is opened it essentially replaces the content of the active document. Maybe the correct fix for all of this is to simply remove auto-focusing and use tabindex appropriately. The spec states browsers should focus content according to the tab order. The spec never mentions tabindex in relation to dialogs. Dialogs are something new and have different behavior than initial page load.
Okay, some clarification is actually needed here. There is some documentation, but it it only applies to modal dialogs. To this regard the spec says when the showModal() method of a dialog is invoked, the user agent must run the following steps:
6. Let dialog's Document be blocked by the modal dialog dialog.
7. Push dialog onto dialog's Document's pending dialog stack.
8. Let control be the first element in tree order whose nearest ancestor dialog element is dialog and that has an autofocus attribute specified, if any.
9. If there is no control, then abort these steps.
10. Run the focusing steps for control.
There is no behavior defined for a modal dialog that does not contain an element with the autofocus attribute (step 9 says to abort). The presumed behavior is that the dialog itself should receive the focus, not the first tabbable element. The spec need not specifically add information about tabindex in regards to modal dialogs as all elements outside the dialog are rendered inert (step 6) and the rules governing sequential focusing and tabindex remain in effect. Additionally, no functionality is defined for non-modal dialogs containing an element with an autofocus attribute (different section).
> The only reason focus is being called during dialog.open() is to prevent the close button from initially gaining focus. That's not at all true. Opening a dialog is literally just showing a div. That has no change on the focus, which means some users are completely lost and have no context for what is going on. THAT is the reason that focus is called. > If the close button were given a high enough tabindex, the browser's own focusing mechanism could choose the appropriate element to focus. Why do you think this would happen?
For a modal dialog without the autofocus attribute applied to any elements, the dialog itself would be focused similar to how the document initially has focus when a page is loaded (All other page elements outside the dialog are inert according to step 6). If it's not a modal dialog, there's no indication that the focus should be changed regardless of it containing an element having the autofocus attribute specified or not.