Skip to content

Conversation

TylerJDev
Copy link
Member

@TylerJDev TylerJDev commented Sep 29, 2025

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

Copy link

changeset-bot bot commented Sep 29, 2025

🦋 Changeset detected

Latest commit: aada341

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

This PR includes changesets to release 2 packages
Name Type
@primer/react Minor
@primer/styled-react Major

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-actions github-actions bot added the staff Author is a staff member label Sep 29, 2025
Copy link
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-actions github-actions bot 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-actions bot temporarily deployed to storybook-preview-6919 September 29, 2025 12:53 Inactive
@github-actions github-actions bot requested a deployment to storybook-preview-6919 October 6, 2025 13:49 Abandoned
@TylerJDev TylerJDev added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 6, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-6919 October 6, 2025 14:02 Inactive
@github-actions github-actions bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 6, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-6919 October 6, 2025 14:15 Inactive
@TylerJDev TylerJDev requested a review from a team as a code owner October 6, 2025 19:15
@TylerJDev TylerJDev requested review from langermank and Copilot and removed request for langermank October 6, 2025 19:15
Copy link
Contributor

@Copilot 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 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.

File Description
packages/react/src/TreeView/TreeView.tsx Main implementation adding count and className support with conditional Button/IconButton rendering
packages/react/src/TreeView/TreeView.examples.stories.tsx Example story demonstrating the new count functionality
.changeset/two-pots-battle.md Changeset documenting the minor version feature addition

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

Copilot AI Oct 6, 2025

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()
}}
Copy link
Preview

Copilot AI Oct 6, 2025

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>
Copy link
Preview

Copilot AI Oct 6, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

1 participant