Visitar URL original
feat!: upgrade to USWDS 3.13.0 by mdmower-csnw · Pull Request #3266 · trussworks/react-uswds · GitHub
Skip to content

feat!: upgrade to USWDS 3.13.0 - #3266

Merged
brandonlenz merged 16 commits into
trussworks:mainfrom
mdmower-csnw:mdm-3.11
Dec 15, 2025
Merged

brandonlenz merged 16 commits into
trussworks:mainfrom
mdmower-csnw:mdm-3.11

Conversation

@mdmower-csnw

@mdmower-csnw mdmower-csnw commented Sep 21, 2025 •

Copy link
Copy Markdown
Contributor

Summary

Apply updates related to features and bug fixes released by USWDS in 3.11.0, 3.12.0, and 3.13.0.

  • Update default error message for file input and apply to aria-label on error
  • Only show in-page navigation if minimum number of headings is found
    • Support setting minimum number of headings via props
  • Include nested headings in in-page navigation
  • Footer story fixes (these changes are not the reason for most Happo differences):
    • Remove incorrectly applied usa-footer__secondary-link class to footer story anchors (the class is applied by the FooterNav component to <li>)
    • Update primary link text in slim and medium FooterNav stories to match the text used in the Footer stories
    • Render only <FooterNav> for the big FooterNav variant, not with <Footer> wrapping it

Additional feature:

Notable omissions:

  • 3.12: The existing i18n support in date picker is a better option than generating locale specific calendar labels based on the HTML lang attribute since only some labels could be generated.
  • 3.12: The tooltip component already supports non-button elements.
  • 3.13: USWDS Elements is still in the earliest stages of support (only usa-banner for now). Dedicated attention to web components support would be best handled by a separate pull request.

Related Issues or PRs

(none)

How To Test

Confirm things work the same as described in USWDS release notes: 3.11.0, 3.12.0, and 3.13.0.

Happo differences

Final visual comparison

@mdmower-csnw mdmower-csnw changed the title feat: upgrade to USWDS 3.11.0 feat: upgrade to USWDS 3.12.0 Sep 21, 2025
@mdmower-csnw mdmower-csnw changed the title feat: upgrade to USWDS 3.12.0 feat: upgrade to USWDS 3.13.0 Sep 24, 2025
@brandonlenz

Copy link
Copy Markdown
Contributor

I saw the patch notes changes to input group classes handling, and tested <InputGroup className="usa-input-group--sm"> on one of the InputPrefix examples. Works as expected.

@brandonlenz

Copy link
Copy Markdown
Contributor

Noticed some odd footer behavior while checking out these changes. Unrelated to this upgrade, so I opened this PR separately: #3334

@mdmower-csnw

mdmower-csnw commented Nov 21, 2025 •

Copy link
Copy Markdown
Contributor Author

@brandonlenz - Just an update on the status of this PR: I added the remaining TODO items to the top of the PR description. I added explanations for most of the Happo differences to the bottom of the description, but I don't have an iPhone/Mac to investigate why the slight margin appeared on iOS Safari for a few page templates. If I were to guess, it's probably related to either the footer spacing changes in uswds/uswds#6237 or the normalization changes in uswds/uswds#5555.

Aside from understanding that change, the one item that requires actual work is "In Page Navigation" stories. Several stories exist in USWDS that don't exist here (including nested headers nav, where I should revert my changes and try to match USWDS): https://federalist-3b6ba08e-0df4-44c9-ac73-6fc193b0e19c.sites.pages.cloud.gov/preview/uswds/uswds/mh/port-banner/?path=/story/components-in-page-navigation--default

UPDATE: in page navigation work is now included and ready for feedback.

@mdmower-csnw
mdmower-csnw marked this pull request as ready for review November 21, 2025 22:53
@mdmower-csnw
mdmower-csnw requested review from a team as code owners November 21, 2025 22:53
@mdmower-csnw mdmower-csnw changed the title feat: upgrade to USWDS 3.13.0 feat!: upgrade to USWDS 3.13.0 Nov 22, 2025
Comment on lines +21 to +43
// If contentSelector is defined, wait to include headings until we've located
// the content element.
if (contentSelector) {
if (contentSelector.startsWith('.')) {
const className = contentSelector.slice(1)
const elHasClass = (el.props?.className as string | undefined)
?.split(' ')
.some((s) => !!s && s === className)
if (elHasClass) {
contentSelector = undefined
}
} else if (contentSelector.startsWith('#')) {
const id = contentSelector.slice(1)
const elHasId = (el.props?.id as string | undefined) === id
if (elHasId) {
contentSelector = undefined
}
} else {
console.warn(
'Only class and id selectors are supported by InPageNavigation contentSelector'
)
return headings
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This manual selector matching isn't something I'm proud of, especially since it's limited to id and class selectors. If in-page nav links should be built using React nodes (<Link>{heading}</Link> below), then trying to match like this pre-render seems to be the only option (would love to be proven incorrect here!).

I can kind of defend the "Only class and id selectors" support by a literal reading of USWDS in-page nav documentation:

Custom main content region selector. The main content selector property (data-main-content-selector) allows you to define which element the component will look in to pull its list of headings. Set the property’s value to the class or id of your page’s main content region (for example, data-main-content-selector=".main-content" or data-main-content-selector="#main-content"). By default, the component will pull headings from the <main> element.

An alternative approach to this problem would be to build the in-page nav after render, using the DOM. This is decidedly not very React-y, though. mdmower-csnw@1d32da2

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.

I'm okay with keeping this as you have it.

This is a component that's quite difficult to make "React-y", IMO, without making it less ergonomic to use

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

I'd like to see the range slider's custom input classes preserved, otherwise I think this is good to go!

In the meantime I'm looking further into the iOS margin/spacing behavior

@brandonlenz

Copy link
Copy Markdown
Contributor

I'm not concerned about the iOS diffs in Happo. I can think of a few reasons why, but they're not important to spend the time confirming. It looks good to me using the iPhone simulator on my mac:

image image

Looks like there's just a uniform 16px padding around everything:

image

which is also what I see running it on firefox on my mac:

image

- Retain `className` assignment to the input
- Introduce `wrapperClassName` for the wrapper
- Update test
@brandonlenz
brandonlenz self-requested a review December 15, 2025 18:04

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

Excellent. Thank you!

@brandonlenz
brandonlenz merged commit 0d96892 into trussworks:main Dec 15, 2025
8 checks passed
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