Skip to content

fix(cdk/a11y): allow for origin of already focused element to be changed #20966

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

Merged
merged 1 commit into from
Nov 7, 2020

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Nov 4, 2020

The way FocusMonitor.focusVia works is by calling focus on the specified element and waiting for a focus event to trigger so the origin is applied. The problem is that if focusVia is called on an element that already has focus, the event won't be dispatched and the origin won't be updated which can cause the UI to look stuck.

These changes make it so that if we detect that an element is focused already, we update its classes and dispatch the relevant event without trying to focus it.

Related to #20965.

@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release labels Nov 4, 2020
@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 4, 2020
@crisbeto crisbeto force-pushed the 20965/focus-monitor-origin branch from 0be46e7 to a2455c6 Compare November 4, 2020 16:51
The way `FocusMonitor.focusVia` works is by calling `focus` on the specified element
and waiting for a `focus` event to trigger so the origin is applied. The problem is that
if `focusVia` is called on an element that already has focus, the event won't be
dispatched and the origin won't be updated which can cause the UI to look stuck.

These changes make it so that if we detect that an element is focused already, we
update its classes and dispatch the relevant event without trying to focus it.

Related to angular#20965.
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Nov 4, 2020
@annieyw annieyw merged commit c1ab0b8 into angular:master Nov 7, 2020
annieyw pushed a commit that referenced this pull request Nov 7, 2020
…ged (#20966)

The way `FocusMonitor.focusVia` works is by calling `focus` on the specified element
and waiting for a `focus` event to trigger so the origin is applied. The problem is that
if `focusVia` is called on an element that already has focus, the event won't be
dispatched and the origin won't be updated which can cause the UI to look stuck.

These changes make it so that if we detect that an element is focused already, we
update its classes and dispatch the relevant event without trying to focus it.

Related to #20965.

(cherry picked from commit c1ab0b8)
annieyw pushed a commit that referenced this pull request Nov 7, 2020
…ged (#20966)

The way `FocusMonitor.focusVia` works is by calling `focus` on the specified element
and waiting for a `focus` event to trigger so the origin is applied. The problem is that
if `focusVia` is called on an element that already has focus, the event won't be
dispatched and the origin won't be updated which can cause the UI to look stuck.

These changes make it so that if we detect that an element is focused already, we
update its classes and dispatch the relevant event without trying to focus it.

Related to #20965.

(cherry picked from commit c1ab0b8)
@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 Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants