details-dialog-element icon indicating copy to clipboard operation
details-dialog-element copied to clipboard

Initial focus should be set to the first focusable element

Open muan opened this issue 4 years ago • 1 comments

https://github.com/github/details-dialog-element/blob/59902d7e420866c30ee288fedcc4f3edfbf8351b/src/index.ts#L10-L17

Initial focus should be set to the first focusable element instead of the dialog element.

@jscholes: Placing focus on the close button is the correct behaviour if the dialog has an accessible name via aria-label or aria-labelledby, which every dialog should. So a screen reader will announce the name, the role of dialog, then the close button.

The focus priority should be as follows:

  1. element with [autofocus]
  2. first focusable element if it's in the beginning of the dialog (usually the close button)
  3. first element

muan avatar Jun 17 '20 22:06 muan

  1. first element

Important to note that if the first element is a heading or other element which is not focusable/interactive by default, it will need a tabindex of "-1". This is critical, because trying to focus a non-focusable element without it will result in no accessible focus movement whatsoever. Which in this case means that a screen reader user won't even know a dialog has opened.

Additional concern: it seems that placing focus on the entire modal container means that Tab navigation is completely broken in the "Legacy" version of Microsoft Edge. For example, when trying to delete an issue or milestone on GitHub, a "Legacy" Edge user can't Tab to the confirm or close buttons.

jscholes avatar Jun 28 '20 19:06 jscholes