Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Fix overeager instantation of govuk-frontend js #110

Merged
merged 4 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,25 @@

#### Features

- Updated to govuk-frontend@3.11.0
- See https://github.com/alphagov/govuk-frontend/releases/tag/v3.11.0 for full release notes
- Cookie banner component added

#### Breaking changes

---

## Releases

### v5.1.0

#### Fixes

- Fix overeager instantiation of govuk JS (https://github.com/surevine/govuk-react-jsx/pull/110)
- Fixes https://github.com/surevine/govuk-react-jsx/issues/99

#### Features

- Updated to govuk-frontend@3.11.0
- See https://github.com/alphagov/govuk-frontend/releases/tag/v3.11.0 for full release notes
- Cookie banner component added

### v5.0.0

- Further ErrorSummary focusing fixes
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "govuk-react-jsx",
"version": "5.0.0",
"version": "5.1.0",
"description": "React component ports of govuk-frontend nunjucks macros. Directly consuming govuk-frontend CSS & JS.",
"main": "src/govuk/index.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/govuk/components/accordion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ function Accordion(props) {
'govuk-frontend/govuk/components/accordion/accordion'
);

new AccordionJS(accordionRef.current).init();
if (accordionRef.current) {
new AccordionJS(accordionRef.current).init();
}
}
})();
}, [accordionRef]);
Expand Down
4 changes: 3 additions & 1 deletion src/govuk/components/button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const Button = React.forwardRef((props, ref) => {
'govuk-frontend/govuk/components/button/button'
);

new ButtonJS(buttonRef.current).init();
if (buttonRef.current) {
new ButtonJS(buttonRef.current).init();
}
}
})();
}, [buttonRef]);
Expand Down
4 changes: 3 additions & 1 deletion src/govuk/components/character-count/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const CharacterCount = React.forwardRef((props, ref) => {
'govuk-frontend/govuk/components/character-count/character-count'
);

new CharacterCountJS(characterCountRef.current).init();
if (characterCountRef.current) {
new CharacterCountJS(characterCountRef.current).init();
}
}
})();
}, [characterCountRef]);
Expand Down
14 changes: 8 additions & 6 deletions src/govuk/components/error-summary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ const ErrorSummary = React.forwardRef((props, ref) => {
'govuk-frontend/govuk/components/error-summary/error-summary'
);

// Just bind the click event handlers from the gov error summary
// This is because we don't want to focus by default - that's up to the calling app
errorSummaryRef.current.addEventListener(
'click',
ErrorSummaryJS.prototype.handleClick.bind(ErrorSummaryJS.prototype)
);
if (errorSummaryRef.current) {
// Just bind the click event handlers from the gov error summary
// This is because we don't want to focus by default - that's up to the calling app
errorSummaryRef.current.addEventListener(
'click',
ErrorSummaryJS.prototype.handleClick.bind(ErrorSummaryJS.prototype)
);
}
}
})();
}, [errorSummaryRef]);
Expand Down
4 changes: 3 additions & 1 deletion src/govuk/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function Header(props) {
'govuk-frontend/govuk/components/header/header'
);

new HeaderJS(headerRef.current).init();
if (headerRef.current) {
new HeaderJS(headerRef.current).init();
}
}
})();
}, [headerRef]);
Expand Down
4 changes: 3 additions & 1 deletion src/govuk/components/notification-banner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ function NotificationBanner(props) {
'govuk-frontend/govuk/components/notification-banner/notification-banner'
);

new NotificationBannerJS(notificationBannerRef.current).init();
if (notificationBannerRef.current) {
new NotificationBannerJS(notificationBannerRef.current).init();
}
}
})();
}, [notificationBannerRef]);
Expand Down
4 changes: 3 additions & 1 deletion src/govuk/components/tabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ function Tabs(props) {
'govuk-frontend/govuk/components/tabs/tabs'
);

new TabsJS(tabsRef.current).init();
if (tabsRef.current) {
new TabsJS(tabsRef.current).init();
}
}
})();
}, [tabsRef]);
Expand Down