Skip to content

Conversation

joshfarrant
Copy link
Contributor

@joshfarrant joshfarrant commented Jul 3, 2025

Summary

Fixes props which were leaking into the DOM, both in Storybook and in the SubdomainNavBar component itself.

List of notable changes:

  • Explicitly destructured props in SubdomainNavBar.stories.tsx to prevent props leaking into the DOM of rendered story.
  • Removed unused showOnlyOnNarrow prop from SubdomainNavBar.tsx to prevent it leaking into the DOM and to fix a related warning in the unit tests.

What should reviewers focus on?

  • I can't see the showOnlyOnNarrow prop being used anywhere, and I'm not sure it was ever implemented since being added in SubdomainNavBar overflow fix #451. Another set of eyes on this would be appreciated though.
  • Check that the SubdomainNavBar still works in the expected way.

Contributor checklist:

  • All new and existing CI checks pass
  • Tests prove that the feature works and covers both happy and unhappy paths
  • Any drop in coverage, breaking changes or regressions have been documented above
  • UI Changes contain new visual snapshots (generated by adding update snapshots label to the PR)
  • All developer debugging and non-functional logging has been removed
  • Related issues have been referenced in the PR description

Reviewer checklist:

  • Check that pull request and proposed changes adhere to our contribution guidelines and code of conduct
  • Check that tests prove the feature works and covers both happy and unhappy paths
  • Check that there aren't other open Pull Requests for the same update/change

Screenshots:

Before After

image

image

Copy link

changeset-bot bot commented Jul 3, 2025

🦋 Changeset detected

Latest commit: bf8c2d5

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

This PR includes changesets to release 8 packages
Name Type
@primer/react-brand Patch
@primer/brand-docs Patch
@primer/brand-css Patch
@primer/brand-primitives Patch
@primer/brand-e2e Patch
@primer/brand-fonts Patch
@primer/brand-config Patch
@primer/brand-storybook 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

@joshfarrant joshfarrant marked this pull request as ready for review July 3, 2025 08:49
@Copilot Copilot AI review requested due to automatic review settings July 3, 2025 08:49
Copy link
Contributor

github-actions bot commented Jul 3, 2025

🟢 No design token changes found

Copy link

@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 prevents unwanted props from appearing in the DOM by removing an unused prop from the component and explicitly destructuring story args.

  • Removed the unused showOnlyOnNarrow prop from SubdomainNavBar.
  • Updated the Storybook template to destructure and exclude showSearch and numLinks.

Reviewed Changes

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

File Description
packages/react/src/SubdomainNavBar/SubdomainNavBar.tsx Removed the showOnlyOnNarrow prop so it no longer leaks into the rendered DOM.
packages/react/src/SubdomainNavBar/SubdomainNavBar.stories.tsx Destructured showSearch and numLinks in the Template signature to avoid prop leakage.
Comments suppressed due to low confidence (1)

packages/react/src/SubdomainNavBar/SubdomainNavBar.tsx:322

  • The showOnlyOnNarrow prop was removed from the JSX, but the component's prop interface and any related documentation or tests may still reference it. Consider cleaning up the SubdomainNavBarProps type and removing any mentions of showOnlyOnNarrow to keep the API contract consistent.
                    )}

@joshfarrant joshfarrant requested a review from rezrah July 3, 2025 08:52
Copy link
Contributor

github-actions bot commented Jul 3, 2025

🟢 No visual differences found

Our visual comparison tests did not find any differences in the UI.

@@ -322,7 +322,6 @@ function Root({
)}
{hasLinks && !menuHidden && (
<NavigationVisbilityObserver
showOnlyOnNarrow
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh wow, so this wasn't doing anything at all? 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No I don't believe so 😅

@joshfarrant joshfarrant merged commit 6531558 into main Jul 10, 2025
18 checks passed
@joshfarrant joshfarrant deleted the joshfarrant/fix-subdomain-nav-bar-leaking-props branch July 10, 2025 13:54
@primer-css primer-css mentioned this pull request Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants