Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 22, 2022. It is now read-only.
This repository was archived by the owner on Sep 22, 2022. It is now read-only.

Initial focus should be set to the first focusable element #59

@muan

Description

@muan

function autofocus(el: DetailsDialogElement): void {
let autofocusElement = Array.from(el.querySelectorAll<HTMLElement>('[autofocus]')).filter(focusable)[0]
if (!autofocusElement) {
autofocusElement = el
el.setAttribute('tabindex', '-1')
}
autofocusElement.focus()
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions