Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

MDCDialog: focus the default button when it is defined #4619

Closed
@yguedidi

Description

MDCDialog uses focus trap as well explained here

This make the first focusable element of the dialog focused.

But the documentation about the default action says "MDC Dialog supports indicating that one of its action buttons represents the default action, triggered by pressing the Enter key. "
Obviously with the first focusable element behavior this is contradictory.

So I suggest that, when a default action button is configured, the mdc-dialog__button--default is set, that the initial focused element become the default action button.

It looks like MDCDialog constructor accepts the initial element to be passed as argument, which would workaround the issue. The proposal here is to make it defaults to the default action button
A fallback tree could looks like this:

  • given element in constructor
  • default action button
  • focus-trap default (first focusable element)

Best of both worlds! Thanks!

Metadata

Assignees

No one assigned

    Labels

    Unresolved (Archived)Open and unresolved issues and PRs that were closed due to archiving the repository.icebox

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions