Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatButton.focus ignores origin argument #17174

Closed
paulferaud opened this issue Sep 23, 2019 · 1 comment · Fixed by #17183
Closed

MatButton.focus ignores origin argument #17174

paulferaud opened this issue Sep 23, 2019 · 1 comment · Fixed by #17183
Assignees

Comments

@paulferaud
Copy link
Contributor

MatButton implements FocusableOption which implements focus(origin?: FocusOrigin). However, it actually implements just focus(unused, extraArgumentsHere).

Reproduction

Use StackBlitz to reproduce your issue: https://stackblitz.com/edit/angular-qrhvfh

Steps to reproduce:

  1. Get reference to MatButton
  2. Call MatButton.focus(origin) where origin = 'keyboard'|'mouse'|whatever

Expected Behavior

Focus should be via 'origin', and class cdk-origin-focused should be applied

Actual Behavior

Focus is always done via 'program' and cdk-program-focused is applied

Workaround

Focus can be done via FocusMonitor instead.

Environment

  • Angular: 7.0.0
  • CDK/Material: 8.1.4
  • Browser(s): Version 77.0.3865.75 (Official Build) (64-bit)
  • Operating System (e.g. Windows, macOS, Ubuntu): Debian Rodette
@devversion devversion self-assigned this Sep 24, 2019
devversion added a commit to devversion/material2 that referenced this issue Sep 24, 2019
It looks like `MatButton` at some point has been refactored
to implement the `FocusableOption` interface so that it can
be used easily iǹ the `FocusKeyManager`.

Currently since the `origin` parameter in the `focus` method
is not respected, the `FocusKeyManager#setFocusOrigin` method
is a noop for button elements. Additionally consumers of
`MatButton` who pass in a specific `FocusOrigin` when calling
the `focus` method will be surprised that the `origin` is simply
ignored (even though it's part of the public method signature; just
prefixed with an underscore).

We should just respect the focus origin to make the method
less confusing and to properly implement the `FocusableOption`.

Fixes angular#17174
devversion added a commit to devversion/material2 that referenced this issue Sep 24, 2019
It looks like `MatButton` at some point has been refactored
to implement the `FocusableOption` interface so that it can
be used easily in the `FocusKeyManager`.

Currently since the `origin` parameter in the `focus` method
is not respected, the `FocusKeyManager#setFocusOrigin` method
is a noop for button elements. Additionally consumers of
`MatButton` who pass in a specific `FocusOrigin` when calling
the `focus` method will be surprised that the `origin` is simply
ignored (even though it's part of the public method signature; just
prefixed with an underscore).

We should just respect the focus origin to make the method
less confusing and to properly implement the `FocusableOption`.

Fixes angular#17174
andrewseguin pushed a commit that referenced this issue Sep 27, 2019
It looks like `MatButton` at some point has been refactored
to implement the `FocusableOption` interface so that it can
be used easily in the `FocusKeyManager`.

Currently since the `origin` parameter in the `focus` method
is not respected, the `FocusKeyManager#setFocusOrigin` method
is a noop for button elements. Additionally consumers of
`MatButton` who pass in a specific `FocusOrigin` when calling
the `focus` method will be surprised that the `origin` is simply
ignored (even though it's part of the public method signature; just
prefixed with an underscore).

We should just respect the focus origin to make the method
less confusing and to properly implement the `FocusableOption`.

Fixes #17174
andrewseguin pushed a commit that referenced this issue Sep 30, 2019
It looks like `MatButton` at some point has been refactored
to implement the `FocusableOption` interface so that it can
be used easily in the `FocusKeyManager`.

Currently since the `origin` parameter in the `focus` method
is not respected, the `FocusKeyManager#setFocusOrigin` method
is a noop for button elements. Additionally consumers of
`MatButton` who pass in a specific `FocusOrigin` when calling
the `focus` method will be surprised that the `origin` is simply
ignored (even though it's part of the public method signature; just
prefixed with an underscore).

We should just respect the focus origin to make the method
less confusing and to properly implement the `FocusableOption`.

Fixes #17174

(cherry picked from commit 1c307c8)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants