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
bug(FocusMonitor): Focus origin of already focused element doesn't change if FocusMonitor is on parent with checkChildren set to true. #21500
Labels
Accessibility
This issue is related to accessibility (a11y)
G
This is is related to a Google internal issue
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Comments
Pinging @crisbeto for his thoughts. |
crisbeto
added
Accessibility
This issue is related to accessibility (a11y)
G
This is is related to a Google internal issue
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
and removed
needs triage
This issue needs to be triaged by the team
labels
Jan 6, 2021
crisbeto
added a commit
to crisbeto/material2
that referenced
this issue
Jan 7, 2021
In angular#20966 some logic was added so that calling `focusVia` on an element that already has focus would change the origin to the passed-in one. The problem is that the new logic doesn't account for when a parent element is monitored and `focusVia` is called on a child. These changes add some more logic that will look through all the monitored elements that have `checkChildren: true` and will switch the origin accordingly. Fixes angular#21500.
crisbeto
added a commit
to crisbeto/material2
that referenced
this issue
Jan 7, 2021
In angular#20966 some logic was added so that calling `focusVia` on an element that already has focus would change the origin to the passed-in one. The problem is that the new logic doesn't account for when a parent element is monitored and `focusVia` is called on a child. These changes add some more logic that will look through all the monitored elements that have `checkChildren: true` and will switch the origin accordingly. Fixes angular#21500.
annieyw
pushed a commit
that referenced
this issue
Jan 9, 2021
In #20966 some logic was added so that calling `focusVia` on an element that already has focus would change the origin to the passed-in one. The problem is that the new logic doesn't account for when a parent element is monitored and `focusVia` is called on a child. These changes add some more logic that will look through all the monitored elements that have `checkChildren: true` and will switch the origin accordingly. Fixes #21500.
annieyw
pushed a commit
that referenced
this issue
Jan 9, 2021
In #20966 some logic was added so that calling `focusVia` on an element that already has focus would change the origin to the passed-in one. The problem is that the new logic doesn't account for when a parent element is monitored and `focusVia` is called on a child. These changes add some more logic that will look through all the monitored elements that have `checkChildren: true` and will switch the origin accordingly. Fixes #21500. (cherry picked from commit f8df9f8)
wagnermaciel
pushed a commit
to wagnermaciel/components
that referenced
this issue
Jan 14, 2021
…r#21512) In angular#20966 some logic was added so that calling `focusVia` on an element that already has focus would change the origin to the passed-in one. The problem is that the new logic doesn't account for when a parent element is monitored and `focusVia` is called on a child. These changes add some more logic that will look through all the monitored elements that have `checkChildren: true` and will switch the origin accordingly. Fixes angular#21500.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Accessibility
This issue is related to accessibility (a11y)
G
This is is related to a Google internal issue
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Explanation
The fix #20966 made it so that the focus origin of an already focused element should change if
focusVia
is called on the element. Unfortunately, this doesn't appear to work if theFocusMonitor
is on a parent element and set up withcheckChildren = true
. This is because the check here (https://github.com/angular/components/pull/20966/files#diff-02e96e7ea6a7d8f1caecdfdbb7cb38bdcdc5c43db34e4392723cc48765e330b7R316) fails, asnativeElement
doesn't have a registeredFocusMonitor
. TheFocusMonitor
is instead registered on the parent.Reproduction
Stackblitz: https://stackblitz.com/edit/angular-ivy-un8eee?file=src/app/hello.component.ts
Steps to reproduce:
document.body
. There is aFocusMonitor
attached to thedocument.body
..cdk-mouse-focused
is first added, and then 5 seconds later, is replaced by the class.cdk-keyboard-focused
. This is expected behavior. When this button is clicked, it callsfocusVia
wthkeyboard
origin on the "Test" button after 5 seconds..cdk-mouse-focused
is present, and never changes to.cdk-keyboard-focused
. This is not expected behavior. I'd expect the class to change to.cdk-keyboard-focused
due to the fix fix(cdk/a11y): allow for origin of already focused element to be changed #20966. Unfortunately it doesn't, because the checkthis._elementInfo.has(nativeElement)
fails withinfocus-monitor.ts
.Environment
The text was updated successfully, but these errors were encountered: