Skip to content

chore: expand support for custom trees#7817

Open
francinelucca wants to merge 15 commits intomainfrom
chore/expand-actionlist-roles
Open

chore: expand support for custom trees#7817
francinelucca wants to merge 15 commits intomainfrom
chore/expand-actionlist-roles

Conversation

@francinelucca
Copy link
Copy Markdown
Member

@francinelucca francinelucca commented May 7, 2026

  • Inspect the requested review comment and related code path
  • Run baseline validation commands before changes
  • Apply the minimal code change for comment r3211420664 only
  • Run targeted tests for TreeView roving tab index behavior
  • Reply to the review comment with the addressing commit hash
  • Run final parallel validation before completion

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 7, 2026

🦋 Changeset detected

Latest commit: de4b18a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

Not sure what this means? Click here to learn what changesets are.

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

@francinelucca francinelucca changed the title chore: expand selectableRoles and listRoleTypes arrays to include 'tr… chore: expand selectableRoles and listRoleTypes arrays to include 'treeitem' and 'tree' May 7, 2026
@francinelucca francinelucca added the Canary Release Apply this label when you want CI to create a canary release of the current PR label May 7, 2026
@github-actions github-actions Bot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels May 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

To publish a canary release for integration testing, apply the Canary Release label to this PR.

@github-actions github-actions Bot requested a deployment to storybook-preview-7817 May 7, 2026 23:35 Abandoned
@github-actions github-actions Bot temporarily deployed to storybook-preview-7817 May 7, 2026 23:45 Inactive
@francinelucca francinelucca changed the title chore: expand selectableRoles and listRoleTypes arrays to include 'treeitem' and 'tree' chore: expand support for custom trees May 8, 2026
@github-actions github-actions Bot requested a deployment to storybook-preview-7817 May 8, 2026 18:26 Abandoned
@github-actions github-actions Bot temporarily deployed to storybook-preview-7817 May 8, 2026 18:34 Inactive
@primer-integration
Copy link
Copy Markdown

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/20288

@francinelucca francinelucca marked this pull request as ready for review May 8, 2026 20:31
@francinelucca francinelucca requested a review from a team as a code owner May 8, 2026 20:31
@francinelucca francinelucca requested review from Copilot and jonrohan and removed request for Copilot May 8, 2026 20:31
@primer-integration
Copy link
Copy Markdown

Integration test results from github/github-ui:

Passed  CI   Passed
Passed  VRT   Passed
Passed  Projects   Passed

All checks passed!

Copy link
Copy Markdown
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

Could we add tests/stories for the new functionality?

Copilot AI review requested due to automatic review settings May 8, 2026 21:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands support for tree-like structures by broadening ActionList’s supported ARIA roles and by making TreeView’s roving-tabindex behavior reusable via a new public useRovingTabIndex export.

Changes:

  • Expanded ActionList.Item role handling to include treeitem and tree.
  • Enhanced useRovingTabIndex with opt-in configuration (e.g. wrap-around, preventScroll, focus-out behavior) and exported it from the package entrypoint.
  • Exposed ActionListContainerContext via ActionList.ContainerContext and added a changeset for a minor release.
Show a summary per file
File Description
packages/react/src/TreeView/useRovingTabIndex.ts Extends roving tabindex logic with new options (wrap-around, focus-out behavior, preventScroll) and improved element resolution.
packages/react/src/index.ts Re-exports useRovingTabIndex from the public API.
packages/react/src/ActionList/Item.tsx Expands selectable/list role allowlists to include treeitem/tree.
packages/react/src/ActionList/index.ts Adds ActionList.ContainerContext static for advanced composition use cases.
packages/react/src/tests/snapshots/exports.test.ts.snap Updates export snapshot to include useRovingTabIndex.
.changeset/expand-actionlist-roles.md Declares a minor bump and describes the new exports/role support.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 3

Comment thread packages/react/src/ActionList/Item.tsx
Comment on lines +5 to +20
export function useRovingTabIndex(
{
containerRef,
bindKeys:
FocusKeys.ArrowVertical |
FocusKeys.ArrowHorizontal |
FocusKeys.HomeAndEnd |
FocusKeys.Backspace |
FocusKeys.PageUpDown,
preventScroll: true,
getNextFocusable: (direction, from, event) => {
if (!(from instanceof HTMLElement)) return

// Skip elements within a modal dialog
// This need to be in a try/catch to avoid errors in
// non-supported browsers
try {
if (from.closest('dialog:modal')) {
return
mouseDownRef,
focusOutBehavior,
preventScroll = true,
wrapAround = false,
}: {
containerRef: React.RefObject<HTMLElement | null>
mouseDownRef?: React.RefObject<boolean>
preventScroll?: boolean
focusOutBehavior?: 'stop' | 'wrap'
wrapAround?: boolean
},
dependencies: React.DependencyList = [],
) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Updated in 5ba0289. I changed useRovingTabIndex to pass [preventScroll, focusOutBehavior, wrapAround, ...dependencies] into useFocusZone, so those options now re-initialize the focus zone when they change while still allowing additional caller-provided dependencies.

Comment thread packages/react/src/TreeView/useRovingTabIndex.ts
@francinelucca
Copy link
Copy Markdown
Member Author

@joshblack added tests in ActionList that test the selection part when role="tree", and added a test file to useRovingTabIndex with general tests as well as the new opt-in features. I don't think it's worth the effort // we get much value out of creating stories for "ActionList as tree" here. Can definitely add if you feel otherwise!

@francinelucca francinelucca requested a review from joshblack May 8, 2026 21:33
@joshblack
Copy link
Copy Markdown
Member

@francinelucca my thought is that functionality that folks can use should be documented in storybook so that they can discover it either in storybook or through the docs site. Let me know what you think 👀

@primer
Copy link
Copy Markdown
Contributor

primer Bot commented May 8, 2026

🤖 Lint issues have been automatically fixed and committed to this PR.

Co-authored-by: francinelucca <40550942+francinelucca@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Canary Release Apply this label when you want CI to create a canary release of the current PR integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants