Add BranchName WithTrailingAction story#7920
Conversation
|
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
9957e42 to
aad16e8
Compare
joshblack
left a comment
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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)
}There was a problem hiding this comment.
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) andWithTrailingActionMenu(SelectPanel anchor) stories underComponents/BranchName/Features. - Extended
e2e/components/BranchName.test.tsto 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
| renderAnchor={anchorProps => ( | ||
| <IconButton | ||
| icon={TriangleDownIcon} | ||
| aria-label="Change base branch" | ||
| variant="invisible" | ||
| size="small" | ||
| className={styles.TrailingActionButton} | ||
| {...anchorProps} | ||
| /> | ||
| )} |
| 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') | ||
| }) | ||
| }) |
| const [copied, setCopied] = React.useState(false) | ||
|
|
||
| const handleCopy = () => { | ||
| setCopied(true) | ||
| void navigator.clipboard.writeText(branchName) | ||
| announce('Copied!') | ||
| setTimeout(() => setCopied(false), 2000) | ||
| } |
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:
Changelog
New
WithTrailingActionstory in BranchName featuresChanged
None
Removed
None
Rollout strategy
Testing & Reviewing
View the story in Storybook: Components > BranchName > Features > With Trailing Action
Merge checklist