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

fix(cdk/tree): capturing focus on load #29641

Merged
merged 1 commit into from
Aug 26, 2024
Merged

Conversation

crisbeto
Copy link
Member

The tree implements a roving tabindex which needs to have an initial item with tabindex = 0 to work correctly. This happens by waiting for the data to be initialized in the TreeKeyManager and focusing the active/first item. The problem is that this ends up stealing focus on load. We didn't notice this issue in the demo app, because all the tree are visibility: hidden since they're inside closed mat-expansion-panel, but the issue is visible in the docs site.

These changes resolve the issue by setting the tabindex without actually moving focus.

Fixes #29628.

The tree implements a roving tabindex which needs to have an initial item with `tabindex = 0` to work correctly. This happens by waiting for the data to be initialized in the `TreeKeyManager` and focusing the active/first item. The problem is that this ends up stealing focus on load. We didn't notice this issue in the demo app, because all the tree are `visibility: hidden` since they're inside closed `mat-expansion-panel`, but the issue is visible in the docs site.

These changes resolve the issue by setting the `tabindex` without actually moving focus.

Fixes angular#29628.
@crisbeto crisbeto added Accessibility This issue is related to accessibility (a11y) target: patch This PR is targeted for the next patch release labels Aug 26, 2024
@crisbeto crisbeto requested a review from a team as a code owner August 26, 2024 07:03
@crisbeto crisbeto requested review from mmalerba and andrewseguin and removed request for a team August 26, 2024 07:03
@crisbeto crisbeto removed the request for review from mmalerba August 26, 2024 20:27
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Aug 26, 2024
@crisbeto crisbeto merged commit 8b34fb7 into angular:main Aug 26, 2024
25 of 27 checks passed
crisbeto added a commit that referenced this pull request Aug 26, 2024
The tree implements a roving tabindex which needs to have an initial item with `tabindex = 0` to work correctly. This happens by waiting for the data to be initialized in the `TreeKeyManager` and focusing the active/first item. The problem is that this ends up stealing focus on load. We didn't notice this issue in the demo app, because all the tree are `visibility: hidden` since they're inside closed `mat-expansion-panel`, but the issue is visible in the docs site.

These changes resolve the issue by setting the `tabindex` without actually moving focus.

Fixes #29628.

(cherry picked from commit 8b34fb7)
essjay05 pushed a commit to essjay05/angular-components that referenced this pull request Aug 26, 2024
The tree implements a roving tabindex which needs to have an initial item with `tabindex = 0` to work correctly. This happens by waiting for the data to be initialized in the `TreeKeyManager` and focusing the active/first item. The problem is that this ends up stealing focus on load. We didn't notice this issue in the demo app, because all the tree are `visibility: hidden` since they're inside closed `mat-expansion-panel`, but the issue is visible in the docs site.

These changes resolve the issue by setting the `tabindex` without actually moving focus.

Fixes angular#29628
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accessibility This issue is related to accessibility (a11y) action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(Tree): Mat Nested Tree node autofocus
2 participants