Skip to content

Support more meaningful options for dialog autoFocus #22678

Closed
@jelbourn

Description

@jelbourn

Currently, the autoFocus option of MatDialogConfig is a boolean, with the values meaning:

  • false - default value, focused the role="dialog" element
  • true - focuses the first tabbable element inside the dialog

This API is kind of confusing, since the dialog automatically focuses something regardless of what you do, so autoFocus: false doesn't really make sense.

Instead, we should change autoFocus to accept these values:

  • dialog - focus the role="dialog" element
  • first-tabbable - focus the first tabbable element
  • first-header - focus the first header (h1 - h6) element in the dialog. It's still an open question whether this should force tabIndex = -1.
  • A CSS selector- arbitrary CSS selector, the dialog would focus the first matching element (vis querySelector). Again an open question if this should force tabIndex = -1.

Metadata

Metadata

Assignees

Labels

AccessibilityThis issue is related to accessibility (a11y)P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentfeatureThis issue represents a new feature or feature request rather than a bug or bug fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions