Skip to content

Add BranchName WithTrailingAction story#7920

Merged
siddharthkp merged 4 commits into
mainfrom
siddharthkp/branchname-trailing-action-story
Jun 15, 2026
Merged

Add BranchName WithTrailingAction story#7920
siddharthkp merged 4 commits into
mainfrom
siddharthkp/branchname-trailing-action-story

Conversation

@siddharthkp

@siddharthkp siddharthkp commented Jun 3, 2026

Copy link
Copy Markdown
Member
  • part 1 of 2 of github/primer#6684
  • My goal with this PR is to first implement it as a story and then in another PR "upstream" it into the component

Overview

Adds a feature story demonstrating the trailing action pattern (copy button) for BranchName. This story serves as a reference for the implementation work to upstream this pattern from github-ui's PullRequestBranchName.

The story demonstrates:

  • Copy button with divider line
  • Hover/focus states
  • Copied state feedback (icon change + tooltip)
  • Accessible announcements via VisuallyHidden + Announce

Changelog

New

  • WithTrailingAction story in BranchName features

Changed

None

Removed

None

Rollout strategy

  • None; story-only change, no component changes yet

Testing & Reviewing

View the story in Storybook: Components > BranchName > Features > With Trailing Action

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Storybook)
  • Changes are SSR compatible
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

@changeset-bot

changeset-bot Bot commented Jun 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1a98046

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

@github-actions github-actions Bot added the staff Author is a staff member label Jun 3, 2026
@siddharthkp siddharthkp added the skip changeset This change does not need a changelog label Jun 3, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-7920 June 3, 2026 11:02 Inactive
@github-actions github-actions Bot temporarily deployed to storybook-preview-7920 June 4, 2026 09:06 Inactive
@github-actions github-actions Bot temporarily deployed to storybook-preview-7920 June 8, 2026 11:13 Inactive
@siddharthkp siddharthkp added integration-tests: skipped manually Changes in this PR do not require an integration test update snapshots 🤖 Command that updates VRT snapshots on the pull request and removed update snapshots 🤖 Command that updates VRT snapshots on the pull request labels Jun 8, 2026
@github-actions github-actions Bot requested a deployment to storybook-preview-7920 June 8, 2026 11:24 Abandoned
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jun 8, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-7920 June 8, 2026 11:40 Inactive
@github-actions github-actions Bot temporarily deployed to storybook-preview-7920 June 8, 2026 11:53 Inactive
@siddharthkp siddharthkp added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jun 8, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-7920 June 8, 2026 12:08 Inactive
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jun 8, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-7920 June 8, 2026 12:19 Inactive
@siddharthkp siddharthkp added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jun 10, 2026
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jun 10, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-7920 June 10, 2026 09:24 Inactive
@github-actions github-actions Bot temporarily deployed to storybook-preview-7920 June 10, 2026 09:34 Inactive
@github-actions github-actions Bot temporarily deployed to storybook-preview-7920 June 10, 2026 09:48 Inactive
Demonstrate a trailing action pattern (copy button) for BranchName,
serving as a reference for future implementation work.

Add WithTrailingActionMenu story with SelectPanel

Demonstrates branch switching via SelectPanel anchored to BranchName,
showing the 'Change base branch' pattern.

Remove overflow:hidden to prevent focus ring clipping
@siddharthkp siddharthkp force-pushed the siddharthkp/branchname-trailing-action-story branch from 9957e42 to aad16e8 Compare June 10, 2026 09:56
@siddharthkp siddharthkp added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jun 10, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-7920 June 10, 2026 09:57 Inactive
@github-actions github-actions Bot temporarily deployed to storybook-preview-7920 June 10, 2026 10:05 Inactive
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Jun 10, 2026
@github-actions github-actions Bot temporarily deployed to storybook-preview-7920 June 10, 2026 10:15 Inactive
@siddharthkp siddharthkp marked this pull request as ready for review June 10, 2026 11:32
@siddharthkp siddharthkp requested a review from a team as a code owner June 10, 2026 11:32
@siddharthkp siddharthkp requested review from Copilot, joshblack and llastflowers and removed request for Copilot June 10, 2026 11:32

@joshblack joshblack left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just had one comment for the live region announcements but wanted to approve in advance so you didn't have to wait another day lol

{/* Screen reader announcement for copy success */}
{copied && (
<VisuallyHidden>
<Announce>Copied!</Announce>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The announcement might be better suited in handleCopy with announce straight from @primer/live-region-element instead of rendering it, in particular if the announcement is hidden. e.g.

import { announce } from '@primer/live-region-element'

 const handleCopy = () => {
    setCopied(true)
    void navigator.clipboard.writeText(branchName)
    announce('Copied!');
    setTimeout(() => setCopied(false), 2000)
  }

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

Copilot AI review requested due to automatic review settings June 15, 2026 10:47

Copilot AI 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

Adds new BranchName “feature” stories to document a trailing-action pattern (copy button + optional menu anchor) and extends the BranchName Playwright VRT coverage to include these new stories and focus/menu states.

Changes:

  • Added story-only CSS module styles to visually compose BranchName with a trailing IconButton action.
  • Added WithTrailingAction (copy) and WithTrailingActionMenu (SelectPanel anchor) stories under Components/BranchName/Features.
  • Extended e2e/components/BranchName.test.ts to snapshot the new stories and their key focus/menu states.
Show a summary per file
File Description
packages/react/src/BranchName/BranchName.stories.module.css Adds story-only layout/styling for a trailing-action container and button divider.
packages/react/src/BranchName/BranchName.features.stories.tsx Adds two new feature stories demonstrating copy and menu trailing actions.
e2e/components/BranchName.test.ts Adds VRT coverage for the new stories, including focus states and menu-open state.

Copilot's findings

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

Comment on lines +112 to +121
renderAnchor={anchorProps => (
<IconButton
icon={TriangleDownIcon}
aria-label="Change base branch"
variant="invisible"
size="small"
className={styles.TrailingActionButton}
{...anchorProps}
/>
)}
Comment on lines +80 to +101
test.describe('With Trailing Action Menu', () => {
test('focus states @vrt', async ({page}) => {
await visit(page, {
id: 'components-branchname-features--with-trailing-action-menu',
globals: {
colorScheme: 'light',
},
})

// Focus on branch name link
await page.keyboard.press('Tab')
await expect(page).toHaveScreenshot('BranchName.With Trailing Action Menu.light.focus-link.png')

// Focus on trailing action button
await page.keyboard.press('Tab')
await expect(page).toHaveScreenshot('BranchName.With Trailing Action Menu.light.focus-button.png')

// Open the menu
await page.keyboard.press('Enter')
await expect(page).toHaveScreenshot('BranchName.With Trailing Action Menu.light.menu-open.png')
})
})
Comment on lines +48 to +55
const [copied, setCopied] = React.useState(false)

const handleCopy = () => {
setCopied(true)
void navigator.clipboard.writeText(branchName)
announce('Copied!')
setTimeout(() => setCopied(false), 2000)
}
@siddharthkp siddharthkp added this pull request to the merge queue Jun 15, 2026
Merged via the queue into main with commit b5315e6 Jun 15, 2026
55 checks passed
@siddharthkp siddharthkp deleted the siddharthkp/branchname-trailing-action-story branch June 15, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: skipped manually Changes in this PR do not require an integration test skip changeset This change does not need a changelog staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants