Skip to content

TreeView: Add count to TreeView trailing actions - #6919

Merged
TylerJDev merged 8 commits into
mainfrom
tylerjdev/add-count-support-trailing-actions
Oct 8, 2025
Merged

TreeView: Add count to TreeView trailing actions#6919
TylerJDev merged 8 commits into
mainfrom
tylerjdev/add-count-support-trailing-actions

Conversation

@TylerJDev

@TylerJDevTylerJDev commented Sep 29, 2025

Copy link
Copy Markdown
Member

Adds className and count support to TreeView trailing actions. This swaps usage of IconButton with Button at times when utilizing count.

Changelog

New

  • Adds ability to utilize count and className with TreeView TrailingActions.

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@changeset-bot

changeset-botBot commented Sep 29, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f9935cf

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

This PR includes changesets to release 2 packages
NameType
@primer/reactMinor
@primer/styled-reactMajor

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

@github-actionsgithub-actionsBot added the staff Author is a staff member label Sep 29, 2025
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@github-actionsgithub-actionsBot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Sep 29, 2025
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6919 September 29, 2025 12:53 Inactive
@github-actions
github-actionsBot requested a deployment to storybook-preview-6919 October 6, 2025 13:49 Abandoned
@TylerJDevTylerJDev added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 6, 2025
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6919 October 6, 2025 14:02 Inactive
@github-actionsgithub-actionsBot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 6, 2025
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6919 October 6, 2025 14:15 Inactive
@TylerJDev
TylerJDev requested a review from a team as a code ownerOctober 6, 2025 19:15
@TylerJDev
TylerJDev requested review from Copilot and langermank and removed request for langermankOctober 6, 2025 19:15

CopilotAI left a comment

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.

Pull Request Overview

This PR enhances the TreeView component by adding count and className support to trailing actions. When a count is provided, the component automatically switches from using IconButton to Button to properly display the count value.

  • Extends the TreeViewSecondaryActions interface to include optional count and className properties
  • Updates the trailing action rendering logic to conditionally use Button with count support or IconButton
  • Adds count display functionality to the action dialog component

Reviewed Changes

Copilot reviewed 3 out of 12 changed files in this pull request and generated 3 comments.

FileDescription
packages/react/src/TreeView/TreeView.tsxMain implementation adding count and className support with conditional Button/IconButton rendering
packages/react/src/TreeView/TreeView.examples.stories.tsxExample story demonstrating the new count functionality
.changeset/two-pots-battle.mdChangeset documenting the minor version feature addition

<>
<div id={trailingActionId} className={clsx('PRIVATE_VisuallyHidden', classes.TreeViewVisuallyHidden)}>
; {shortcutText}
- {shortcutText}

CopilotAIOct 6, 2025

Copy link

Choose a reason for hiding this comment

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

Changed semicolon to hyphen in visually hidden text. This appears to be an unintended character change that should be reverted.

Suggested change
-{shortcutText}
;{shortcutText}

Copilot uses AI. Check for mistakes.
Comment on lines +769 to +775
onKeyDown={() => {
// hack to send focus back to the tree item after the action is triggered via click
// this is needed because the trailing action shouldn't be focused, as it does not interact well with
// the focus management of TreeView
const parentElement = document.getElementById(itemId)
parentElement?.focus()
}}

CopilotAIOct 6, 2025

Copy link

Choose a reason for hiding this comment

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

The focus management logic is duplicated between the Button and IconButton implementations. Consider extracting this into a shared function to reduce code duplication.

Copilot uses AI. Check for mistakes.
{count ? (
<ActionList.TrailingVisual>
{count}
<VisuallyHidden>items</VisuallyHidden>

CopilotAIOct 6, 2025

Copy link

Choose a reason for hiding this comment

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

The hardcoded 'items' text may not be appropriate for all use cases of count. Consider making this text configurable or using more generic language like 'count' to better represent various counting scenarios.

Copilot uses AI. Check for mistakes.
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6919 October 8, 2025 18:25 Inactive
@TylerJDev
TylerJDev added this pull request to the merge queueOct 8, 2025
Merged via the queue into main with commit 32e12c6Oct 8, 2025
42 of 43 checks passed
@TylerJDev
TylerJDev deleted the tylerjdev/add-count-support-trailing-actions branch October 8, 2025 20:15
@primerprimerBot mentioned this pull request Oct 8, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommendedThis change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpmstaffAuthor is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@TylerJDev@francinelucca