Skip to content

Add className support to UnderlineNav.Item component #6129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 28, 2025
Merged

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented May 28, 2025

Changes

The UnderlineNav.Item component was not properly combining custom className props with the default styling. This PR fixes the issue by:

  1. Modifying the UnderlineItem component in UnderlineTabbedInterface.tsx to:

    • Accept the className prop
    • Use clsx to combine the default className with any user-provided className
  2. Added a test case to verify that className props are correctly combined with the default classes

This change aligns with our contribution guidelines:

Each component should accept a prop called className that allows for consumers to pass along a custom class. Only pass a className to the top level dom element of each component and sub component.

For multiple classnames, use clsx to merge them together.

Before

<UnderlineNav.Item className="my-custom-class">
  Item
</UnderlineNav.Item>
// Only renders with default class, ignores "my-custom-class"

After

<UnderlineNav.Item className="my-custom-class">
  Item
</UnderlineNav.Item>
// Renders with both default class and "my-custom-class"

Fixes #6128.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link

changeset-bot bot commented May 28, 2025

🦋 Changeset detected

Latest commit: 37a7ff6

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 Patch

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

Co-authored-by: jonrohan <54012+jonrohan@users.noreply.github.com>
@jonrohan jonrohan marked this pull request as ready for review May 28, 2025 17:28
@Copilot Copilot AI review requested due to automatic review settings May 28, 2025 17:28
@jonrohan jonrohan requested a review from a team as a code owner May 28, 2025 17:28
@jonrohan jonrohan requested a review from francinelucca May 28, 2025 17:28
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 May 28, 2025
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 fixes the issue where passing a className to UnderlineNav.Item wasn’t merged with the default styling. It updates the internal UnderlineItem component to use clsx for class merging and adds a test to verify the behavior.

  • Use clsx to combine classes.UnderlineItem with any passed className
  • Added a test in UnderlineNav.test.tsx to assert both default and custom classes are applied

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/react/src/internal/components/UnderlineTabbedInterface.tsx Destructure and merge className using clsx
packages/react/src/UnderlineNav/UnderlineNav.test.tsx New test asserting className is combined properly
Comments suppressed due to low confidence (2)

packages/react/src/internal/components/UnderlineTabbedInterface.tsx:114

  • Ensure that clsx is imported at the top of this file (e.g., import clsx from 'clsx';), otherwise the build will fail.
className={clsx(classes.UnderlineItem, className)}

packages/react/src/internal/components/UnderlineTabbedInterface.tsx:104

  • Consider updating the UnderlineItemProps TypeScript definition or JSDoc for this component to explicitly include className, so IDE users know it’s supported.
className,

@Copilot Copilot AI changed the title [WIP] UnderlineNav.Item component doesn't combine className Add className support to UnderlineNav.Item component May 28, 2025
@Copilot Copilot AI requested a review from jonrohan May 28, 2025 17:31
Copilot finished work on behalf of jonrohan May 28, 2025 17:31
Copy link
Contributor

github-actions bot commented May 28, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 94.43 KB (-0.04% 🔽)
packages/react/dist/browser.umd.js 94.56 KB (+0.03% 🔺)

@github-actions github-actions bot requested a deployment to storybook-preview-6129 May 28, 2025 17:31 Abandoned
@jonrohan
Copy link
Member

@copilot Can you fix these lint and format CI errors?

Co-authored-by: jonrohan <54012+jonrohan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented May 28, 2025

@copilot Can you fix these lint and format CI errors?

Fixed the lint and format errors. The issues were prettier formatting violations (missing trailing comma and improper indentation). All linting tools now pass successfully. (2334668)

Copilot finished work on behalf of jonrohan May 28, 2025 17:45
@github-actions github-actions bot temporarily deployed to storybook-preview-6129 May 28, 2025 17:46 Inactive
@jonrohan jonrohan enabled auto-merge May 28, 2025 18:08
@github-actions github-actions bot temporarily deployed to storybook-preview-6129 May 28, 2025 18:17 Inactive
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@francinelucca
Copy link
Member

@copilot fix the broken test

Copilot finished work on behalf of francinelucca May 28, 2025 22:23
Co-authored-by: Jon Rohan <yes@jonrohan.codes>
Copilot finished work on behalf of jonrohan May 28, 2025 22:28
@jonrohan jonrohan added this pull request to the merge queue May 28, 2025
Merged via the queue into main with commit 1a15bac May 28, 2025
35 checks passed
@jonrohan jonrohan deleted the copilot/fix-6128 branch May 28, 2025 22:50
@primer primer bot mentioned this pull request May 28, 2025
@primer-integration
Copy link

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

@primer-integration
Copy link

🔴 golden-jobs completed with status failure.

@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: failing Changes in this PR cause breaking changes in gh/gh
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UnderlineNav.Item component doesn't combine className
3 participants