Skip to content

Fix TreeView selection state transfer when loader nodes are replaced#3913

Closed
Copilot wants to merge 5 commits intochore/add-treeview-rolefrom
copilot/fix-github-actions-workflow
Closed

Fix TreeView selection state transfer when loader nodes are replaced#3913
Copilot wants to merge 5 commits intochore/add-treeview-rolefrom
copilot/fix-github-actions-workflow

Conversation

Copy link
Contributor

Copilot AI commented Feb 4, 2026

Analysis Summary

PR #3894 made changes to:

  1. tree_view_sub_tree_node_element.ts - Added role="treeitem" to shadow DOM nodes
  2. tree_view_test.rb - Changed one test from using :down to :tab key

The changes affect TreeView keyboard navigation behavior when dealing with loader nodes.

Original prompt

Fix the failing GitHub Actions workflow System (chrome)
Analyze the workflow logs, identify the root cause of the failure, and implement a fix.
Job ID: 62525084772
Job URL: https://github.com/primer/view_components/actions/runs/21683755421/job/62525084772


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2026

⚠️ No Changeset found

Latest commit: ba4fd23

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

When a loader (spinner/skeleton) node is selected and replaced with actual content,
the selection state (aria-selected) now properly transfers to the first loaded node.
This ensures keyboard navigation maintains the expected selection state.

Co-authored-by: francinelucca <[email protected]>
Copilot AI changed the title [WIP] Fix failing GitHub Actions workflow for chrome Fix TreeView selection state transfer when loader nodes are replaced Feb 4, 2026
Copilot AI requested a review from francinelucca February 4, 2026 19:13
The previous fix only checked if the loader was focused, but the test flow
shows that focus can move away before the content loads. The correct fix
is to check if the loader node has aria-selected=true (regardless of focus)
and transfer that selection to the first loaded node when content replaces
the loader.

This handles both cases:
1. Loader is focused when replaced → focus moves to first child
2. Loader has aria-selected=true → selection transfers to first child

Co-authored-by: francinelucca <[email protected]>
Extract common logic for finding the first loaded node into a helper function
to improve code maintainability and reduce duplication.

Co-authored-by: francinelucca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants