Skip to content

Commit 454225a

Browse files
committed
Simplify Fieldset component and introduce FormGroup
1 parent 6d09861 commit 454225a

File tree

33 files changed

+371
-155
lines changed

33 files changed

+371
-155
lines changed

CHANGELOG.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,65 @@
22

33
## Unreleased
44

5+
This version updates nhsuk-frontend to version 9.
6+
7+
For a full list of changes in this release please refer to the [migration doc](https://github.com/NHSDigital/nhsuk-react-components/blob/main/docs/upgrade-to-5.0.md).
8+
9+
## 4.1.3 - 23 September 2024
10+
511
:wrench: **Fixes**
6-
* Remove the unnecessary aria-labelledby tags from radio items. PR [#253](https://github.com/NHSDigital/nhsuk-react-components/pull/253)
712

13+
- Remove the unnecessary aria-labelledby tags from radio items. PR [#253](https://github.com/NHSDigital/nhsuk-react-components/pull/253)
814

915
## 4.1.2 - 3 September 2024
1016

1117
:wrench: **Fixes**
1218

13-
* Fix issues with SkipLink (always set the href) and bring into line with NHSUK frontend. PR [#248](https://github.com/NHSDigital/nhsuk-react-components/pull/248)
19+
- Fix issues with SkipLink (always set the href) and bring into line with NHSUK frontend. PR [#248](https://github.com/NHSDigital/nhsuk-react-components/pull/248)
1420

1521
## 4.1.1 - 9 August 2024
1622

1723
:wrench: **Fixes**
1824

19-
* Remove the unnecessary aria-labelledby tags from DateInput fields. PR [#246](https://github.com/NHSDigital/nhsuk-react-components/pull/246)
25+
- Remove the unnecessary aria-labelledby tags from DateInput fields. PR [#246](https://github.com/NHSDigital/nhsuk-react-components/pull/246)
2026

2127
## 4.1.0 - 11 June 2024
2228

2329
:wrench: **Fixes**
2430

25-
* Add js shims for buttons. PR [#231](https://github.com/NHSDigital/nhsuk-react-components/pull/231), Fixes [#218](https://github.com/NHSDigital/nhsuk-react-components/issues/218)
26-
* Fix errors not being linked to inputs. PR [#230](https://github.com/NHSDigital/nhsuk-react-components/pull/230), Fixes [#227](https://github.com/NHSDigital/nhsuk-react-components/issues/227)
27-
* Fix inputs incorrectly using `aria-labelledby`. PR [#230](https://github.com/NHSDigital/nhsuk-react-components/pull/230), Fixes [#212](https://github.com/NHSDigital/nhsuk-react-components/issues/212)
28-
* Update Storybook docs for several components.
31+
- Add js shims for buttons. PR [#231](https://github.com/NHSDigital/nhsuk-react-components/pull/231), Fixes [#218](https://github.com/NHSDigital/nhsuk-react-components/issues/218)
32+
- Fix errors not being linked to inputs. PR [#230](https://github.com/NHSDigital/nhsuk-react-components/pull/230), Fixes [#227](https://github.com/NHSDigital/nhsuk-react-components/issues/227)
33+
- Fix inputs incorrectly using `aria-labelledby`. PR [#230](https://github.com/NHSDigital/nhsuk-react-components/pull/230), Fixes [#212](https://github.com/NHSDigital/nhsuk-react-components/issues/212)
34+
- Update Storybook docs for several components.
2935

3036
:new: **New features**
3137

32-
* Added a CHANGELOG to keep track of changes between releases. [Keep a changelog](https://keepachangelog.com)
33-
* Added support for `preventDoubleClick` debouncing on buttons. PR [#231](https://github.com/NHSDigital/nhsuk-react-components/pull/231)
34-
* Error summaries now automatically set role, tabindex, and aria-labelledby. PR [#229](https://github.com/NHSDigital/nhsuk-react-components/pull/237), Fixes [#228](https://github.com/NHSDigital/nhsuk-react-components/issues/229)
35-
* Storybook link in readme now points to latest version. PR [#226](https://github.com/NHSDigital/nhsuk-react-components/pull/226)
38+
- Added a CHANGELOG to keep track of changes between releases. [Keep a changelog](https://keepachangelog.com)
39+
- Added support for `preventDoubleClick` debouncing on buttons. PR [#231](https://github.com/NHSDigital/nhsuk-react-components/pull/231)
40+
- Error summaries now automatically set role, tabindex, and aria-labelledby. PR [#229](https://github.com/NHSDigital/nhsuk-react-components/pull/237), Fixes [#228](https://github.com/NHSDigital/nhsuk-react-components/issues/229)
41+
- Storybook link in readme now points to latest version. PR [#226](https://github.com/NHSDigital/nhsuk-react-components/pull/226)
3642

3743
## 4.0.2 - 21 May 2024
3844

3945
:wrench: **Fixes**
4046

41-
* Fix error message role by @edwardhorsford in [#219](https://github.com/NHSDigital/nhsuk-react-components/pull/219)
47+
- Fix error message role by @edwardhorsford in [#219](https://github.com/NHSDigital/nhsuk-react-components/pull/219)
4248

4349
## 4.0.1 - 20 May 2024
4450

4551
:wrench: **Fixes**
4652

47-
* Fix issue with the footer copyright not being rendered in the correct location if there are multiple link columns by @jakeb-nhs in [#223](https://github.com/NHSDigital/nhsuk-react-components/pull/223)
53+
- Fix issue with the footer copyright not being rendered in the correct location if there are multiple link columns by @jakeb-nhs in [#223](https://github.com/NHSDigital/nhsuk-react-components/pull/223)
4854

4955
## 4.0.0 - 15 May 2024
5056

5157
This version updates nhsuk-frontend to version 8.
5258

53-
For a full list of changes in this release please refer to the [migration doc](https://github.com/NHSDigital/nhsuk-react-components/blob/feature/nhsuk-frontend-v8/docs/upgrade-to-4.0.md).
59+
For a full list of changes in this release please refer to the [migration doc](https://github.com/NHSDigital/nhsuk-react-components/blob/main/docs/upgrade-to-4.0.md).
5460

55-
* Migrate enzyme to react-testing-library by @JoshuaBates-NHS in [#198](https://github.com/NHSDigital/nhsuk-react-components/pull/198)
56-
* Allow support for module directives in build process by @JoshuaBates-NHS in [#199](https://github.com/NHSDigital/nhsuk-react-components/pull/199)
57-
* Update modified components since NHS UK frontend v5 by @jakeb-nhs in [#197](https://github.com/NHSDigital/nhsuk-react-components/pull/197)
58-
* Add new components since NHS UK frontend v5 by @jakeb-nhs in [#202](https://github.com/NHSDigital/nhsuk-react-components/pull/202)
59-
* Migrate some patterns to components, rework removed components from frontend v8 by @jakeb-nhs in [#203](https://github.com/NHSDigital/nhsuk-react-components/pull/203)
60-
* Improve unit test coverage by @jakeb-nhs in [#204](https://github.com/NHSDigital/nhsuk-react-components/pull/204)
61+
- Migrate enzyme to react-testing-library by @JoshuaBates-NHS in [#198](https://github.com/NHSDigital/nhsuk-react-components/pull/198)
62+
- Allow support for module directives in build process by @JoshuaBates-NHS in [#199](https://github.com/NHSDigital/nhsuk-react-components/pull/199)
63+
- Update modified components since NHS UK frontend v5 by @jakeb-nhs in [#197](https://github.com/NHSDigital/nhsuk-react-components/pull/197)
64+
- Add new components since NHS UK frontend v5 by @jakeb-nhs in [#202](https://github.com/NHSDigital/nhsuk-react-components/pull/202)
65+
- Migrate some patterns to components, rework removed components from frontend v8 by @jakeb-nhs in [#203](https://github.com/NHSDigital/nhsuk-react-components/pull/203)
66+
- Improve unit test coverage by @jakeb-nhs in [#204](https://github.com/NHSDigital/nhsuk-react-components/pull/204)

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ class GetStartedButton extends PureComponent {
3838

3939
## Upgrading
4040

41-
* [Upgrading to 1.0](/docs/upgrade-to-1.0.md)
42-
* [Upgrading to 2.0](/docs/upgrade-to-2.0.md)
43-
* [Upgrading to 3.0](/docs/upgrade-to-3.0.md)
44-
* [Upgrading to 4.0](/docs/upgrade-to-4.0.md)
41+
- [Upgrading to 1.0](/docs/upgrade-to-1.0.md)
42+
- [Upgrading to 2.0](/docs/upgrade-to-2.0.md)
43+
- [Upgrading to 3.0](/docs/upgrade-to-3.0.md)
44+
- [Upgrading to 4.0](/docs/upgrade-to-4.0.md)
45+
- [Upgrading to 5.0](/docs/upgrade-to-5.0.md)
4546

4647
## Maintainers
4748

docs/upgrade-to-5.0.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Upgrading to 5.0
2+
3+
## Breaking changes
4+
5+
## New Features
6+
7+
### FormGroup
8+
9+
In order to provide consumers of this library more control over when to render fieldsets, some behaviour of the previous `Fieldset` component has been extracted into a new `FormGroup` component. This makes `FormGroup` responsible for rendering the error decorator line for groups of inputs, and `Fieldset` is now a simpler component which makes use of this component.
10+
11+
No changes are required for existing usages of `Fieldset`. For examples of the usage of `FormGroup`, please see storybook.
12+
13+
For example, this:
14+
15+
```
16+
<Fieldset>
17+
<Fieldset.Legend>What is your address?</Fieldset.Legend>
18+
<TextInput id="address-1" />
19+
<TextInput id="address-2" />
20+
</Fieldset>
21+
```
22+
23+
Would become this:
24+
25+
```
26+
<InputGroup>
27+
<Fieldset>
28+
<Fieldset.Legend>What is your address?</Fieldset.Legend>
29+
<TextInput id="address-1" />
30+
<TextInput id="address-2" />
31+
</Fieldset>
32+
</InputGroup>
33+
```
34+
35+
Which also allows consumers to omit the `Fieldset` if rendering a single input:
36+
37+
```
38+
<InputGroup>
39+
<HeadingLevel headingLevel="h3">What is your address?</HeadingLevel>
40+
<TextInput id="address-1" />
41+
</InputGroup>
42+
```

src/__tests__/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe('Index', () => {
3636
'Fieldset',
3737
'Footer',
3838
'Form',
39+
'FormGroup',
3940
'Header',
4041
'Hero',
4142
'HintText',

src/components/content-presentation/do-and-dont-list/DoAndDontList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React, { FC, HTMLProps, createContext, useContext, ReactNode } from 'react';
33
import classNames from 'classnames';
44
import { Tick, Cross } from '@components/content-presentation/icons';
5-
import HeadingLevel, { HeadingLevelType } from '@util/HeadingLevel';
5+
import HeadingLevel, { HeadingLevelType } from '@components/utils/HeadingLevel';
66

77
type ListType = 'do' | 'dont';
88

src/components/content-presentation/hero/Hero.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { FC, HTMLProps } from 'react';
22
import classNames from 'classnames';
33
import { Container, Row, Col } from '../../layout';
4-
import HeadingLevel, { HeadingLevelType } from '@util/HeadingLevel';
4+
import HeadingLevel, { HeadingLevelType } from '@components/utils/HeadingLevel';
55

66
interface HeroContentProps extends HTMLProps<HTMLDivElement> {
77
hasImage: boolean;

src/components/content-presentation/table/components/TablePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { FC, ComponentProps, HTMLProps } from 'react';
22
import classNames from 'classnames';
3-
import HeadingLevel from '@util/HeadingLevel';
3+
import HeadingLevel from '@components/utils/HeadingLevel';
44

55
export interface TablePanelProps extends HTMLProps<HTMLDivElement> {
66
heading?: string;

src/components/content-presentation/tabs/Tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22
import classNames from 'classnames';
33
import React, { FC, HTMLAttributes, useEffect } from 'react';
4-
import HeadingLevel, { HeadingLevelType } from '@util/HeadingLevel';
4+
import HeadingLevel, { HeadingLevelType } from '@components/utils/HeadingLevel';
55
import TabsJs from '@resources/tabs';
66

77
type TabsProps = HTMLAttributes<HTMLDivElement>;

src/components/content-presentation/tabs/__tests__/Tabs.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { fireEvent, render } from '@testing-library/react';
33
import Tabs from '../Tabs';
4-
import { HeadingLevelType } from '@util/HeadingLevel';
4+
import { HeadingLevelType } from '@components/utils/HeadingLevel';
55

66
describe('The tabs component', () => {
77
it('Matches the snapshot', () => {

src/components/content-presentation/warning-callout/WarningCallout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { FC, HTMLProps } from 'react';
22
import classNames from 'classnames';
3-
import HeadingLevel, { HeadingLevelType } from '@util/HeadingLevel';
3+
import HeadingLevel, { HeadingLevelType } from '@components/utils/HeadingLevel';
44

55
interface WarningCalloutLabelProps extends HTMLProps<HTMLHeadingElement> {
66
headingLevel?: HeadingLevelType;

0 commit comments

Comments
 (0)