-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Labels
Context: JavaScriptIssue is in JavaScriptIssue is in JavaScriptPackage: BannerRole: DevDevelopment/engineering skills neededDevelopment/engineering skills needed
Milestone
Description
Describe the bug
Banner fails to initialize properly because:
- Component doesn't have its own init method.
- There's a requirement to USA accordion JS that's not called.
Steps to reproduce the bug
- Create a banner component in react
- Try to initialize based on react hooks example
// UsaBanner.jsx
import { useEffect } from "react";
import banner from "@uswds/uswds/js/usa-banner/";
function UsaBanner() {
useEffect(() => {
const ref = document.body;
// window.uswds
// initialize
banner.on(ref);
return () => {
banner.off();
};
});
…component markup
Expected Behavior
Component should initialize in react without requiring uswds-init.
Screenshots
No response
System setup
- USWDS version: 3.4.0
Additional context
Outdated notes
Affected components
BannerHeaderModal
These components currently depend on usa-js-loading
class from uswds-init.js
. Users of dynamic frameworks will have unexpected results when trying to initialize.
For example, in the case of banner: the banner will appear expanded and won't toggle properly.
Code of Conduct
- I agree to follow this project's Code of Conduct.
- I checked the current issues for duplicate bug reports.
Metadata
Metadata
Assignees
Labels
Context: JavaScriptIssue is in JavaScriptIssue is in JavaScriptPackage: BannerRole: DevDevelopment/engineering skills neededDevelopment/engineering skills needed
Type
Projects
Status
Done