Skip to content

fix(cdk-experimental/ui-patterns): Tree expand/collapse key should work in follow focus mode #31747

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
Aug 21, 2025

Conversation

ok7sai
Copy link
Member

@ok7sai ok7sai commented Aug 20, 2025

No description provided.

@ok7sai ok7sai requested a review from wagnermaciel August 20, 2025 22:24
@ok7sai ok7sai requested a review from a team as a code owner August 20, 2025 22:24
@ok7sai ok7sai requested review from crisbeto and removed request for a team August 20, 2025 22:24
@ok7sai ok7sai added the dev-app preview When applied, previews of the dev-app are deployed to Firebase label Aug 20, 2025
Copy link

Deployed dev-app for 393838e to: https://ng-dev-previews-comp--pr-angular-components-31747-dev-o4qdongt.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

@wagnermaciel
Copy link
Contributor

I noticed a bug that might be related

Steps to reproduce

  1. Click to expand the "src" tree item in the "Active Descendant" tree
  2. Click "main.ts"
  3. Press the left arrow key to move focus to the parent tree item
  4. Press the left arrow key to close the parent tree item

@ok7sai
Copy link
Member Author

ok7sai commented Aug 21, 2025

I noticed the focus outline did not change? Is that the bug you referred to?

If so, I think that's the styling issue that .example-selectable:focus-within only works with pointer clicks, and I can spot the same issue in other patterns when active descendant mode is on.

@wagnermaciel
Copy link
Contributor

No, the focus ring is ok. The result of following those steps is the tree loses focus entirely. Focus returns to the document body

@ok7sai
Copy link
Member Author

ok7sai commented Aug 21, 2025

I think that's the natural of mixed using pointer and keyboard.

  1. Click to expand the "src" tree item in the "Active Descendant" tree (document.activeElement => src)
  2. Click "main.ts" (document.activeElement => main.ts)
  3. Press the left arrow key to move focus to the parent tree item (main.ts still in the page, so document.activeElement => main.ts)
  4. Press the left arrow key to close the parent tree item (now main.ts is removed, so document.activeElement automatically moves focus back to body)

tabindex="-1" only makes an element no longer tabbable, but they are can still receive focus via pointer events. For accessibility it shouldn't be a concern because

  1. Pure keyboard users rely on screen readers won't encounter the issue.
  2. If they can use a mouse/pointer, then the focus doesn't matter.

@wagnermaciel
Copy link
Contributor

I created #31756 to handle the other issue separately

@ok7sai ok7sai added action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release labels Aug 21, 2025
@ok7sai ok7sai removed the request for review from crisbeto August 21, 2025 16:52
@ok7sai ok7sai merged commit df0d753 into angular:main Aug 21, 2025
25 of 28 checks passed
@ok7sai ok7sai deleted the ng-aria-tree branch August 21, 2025 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker dev-app preview When applied, previews of the dev-app are deployed to Firebase target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants