Skip to content

feat(material): Allow focus origin to be an optional input to focus() methods. #20858

Closed
@jesscxu

Description

@jesscxu

Feature Description

WHAT: For Angular Material components that have a focus() method, allow for the origin param to be optional and remove the default origin value.

WHY: For cases where the focus() method is called and the origin is already defined, we don’t want to override the origin using focusVia to always be some default value. In many cases, we want to leave the origin unchanged, but if there are cases that need the origin to be updated, allow for this with an optional origin param.

Use Case

If the focus origin value is keyboard, and some interaction happens where we want to set focus to another element somewhere on the page by explicitly calling focus(), then in cases where the focus origin should remain the same, the current implementation causes the origin to change and the interaction to be weird. This is also due to the fact that we use a single, global focus monitor attached to the document body in eventual detection mode.

Here are the components to update:
-button
-checkbox
-menu item
-menu trigger
-radio
-expansion panel header
-slide toggle
-step header

Metadata

Metadata

Assignees

No one assigned

    Labels

    GThis is is related to a Google internal issueP4A relatively minor issue that is not relevant to core functionsfeatureThis 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