Visitar URL original
USWDS - Multiple Enhanced Components: Fixed initialization issues by olsonap · Pull Request #6664 · uswds/uswds · GitHub
Skip to content

USWDS - Multiple Enhanced Components: Fixed initialization issues - #6664

Merged
msbtterswrth merged 15 commits into
uswds:developfrom
olsonap:uswds-6663-enhanced_component_and_story_fixes
Jun 2, 2026
Merged

msbtterswrth merged 15 commits into
uswds:developfrom
olsonap:uswds-6663-enhanced_component_and_story_fixes

Conversation

@olsonap

@olsonap olsonap commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixed initialization issues for dynamically rendered, enhanced components. Fixed Time Picker, File Input, Range, Date Picker, and Character Count init methods to prevent re-enhancement while updating all enhanced component stories.

Breaking change

This is not a breaking change.

Related issue

Closes #6663

Related pull requests

None

Preview link

Preview link:
Not available

Problem statement

The USWDS Storybook app doesn't initialize enhanced components when the story renders.
Some of the consequences:

--ComboBox renders like a select component.
--Accordions render with all of the accordions open.
--DatePicker and DateRangePicker don't have the calendar to interact with.
--Header renders with nav items open.
--CharacterCount is static, with no soft failure state, and no feedback on remaining characters.
--TimePicker is just an empty text input.
--FileInput styling is missing.

While solving the problem above, I found that the init methods of Time Picker, File Input, Range, Date Picker, and Character Count could be repeatedly enhanced, which results in unpredictable rendering behavior.

Solution

  1. Enhanced components need to be initialized after mount in order to render/function properly.
    -- Each enhanced component story has been updated with an initialization decorator.
  2. Time Picker, File Input, and Range weren't initializing properly because they didn't prevent re-enhancement.
    -- They are now marked during the first init() pass to prevent this. The appropriate element is marked with a data-enhanced attribute after enhancement. At the start of enhancement, the appropriate element is checked for a truthy data-enhanced attribute.
    -- This solution was chosen because it's the same way ComboBox prevents re-enhancement.

Major changes

Minor (IMO)

Testing and review

Clone the repo, checkout this branch, execute npm install && npm start.
Manipulate and visually inspect the components affected by this PR.

Here are screenshots to show it's resolved:

ComboBox:
image

Accordions:
image

DatePicker:
image

DateRangePicker:
image

Header:
image

CharacterCount:
image
image

TimePicker:
image

FileInput:
image

olsonap added 3 commits May 20, 2026 04:53
Added component initialization for TimePicker and FileInput stories
Initializing range slider stories using on() function
@olsonap

olsonap commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

Additional components identified:
Modal
Tooltip
Sortable Tables

Before:
image

After:
image

@olsonap

olsonap commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

Also addressed the Forms examples including the Disabled and Error States:
image
image
image
image

@NSKbot

NSKbot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Hi @olsonap! Thank you so much for your contribution that's under review. We're currently expanding our community management of USWDS – thank you in advance for your patience while we scale things up!

@annepetersen Going off of the responsibilities for new contributors, is the idea that @msbtterswrth and myself should currently be able to initiate a CodeQL scan directly in this repo?

@annepetersen

annepetersen commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

@NSKbot Yep, you should be able to approve workflows to run, but I haven't poked into changing that for you yet. Give me a sec to find and change that setting for y'all.

@chandracarney chandracarney added Affects: Usability Relates to the usability of our code or components Role: Dev Dev expertise is relevant. Project Active Role tracks ownership; this label is not an assignment. labels May 26, 2026

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

Thanks for the great work here!

@msbtterswrth
msbtterswrth merged commit 641f55d into uswds:develop Jun 2, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Triage to Fed Final Review in USWDS Core Project Data Jun 2, 2026
@ethangardner ethangardner mentioned this pull request Jun 2, 2026
@annepetersen

Copy link
Copy Markdown
Contributor

Though, uh, @NSKbot, to make any of the above happen, you'll need to accept the invitation to join the repo 😅 (looks like it expired; I just re-sent it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Affects: Usability Relates to the usability of our code or components Role: Dev Dev expertise is relevant. Project Active Role tracks ownership; this label is not an assignment. ❤️ Thanks Historical appreciation marker. Prefer a reaction; not required for triage.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants