Skip to content

Commit 9babe66

Browse files
Document breaking changes
1 parent 9170054 commit 9babe66

File tree

1 file changed

+346
-0
lines changed

1 file changed

+346
-0
lines changed

docs/upgrade-to-6.0.md

Lines changed: 346 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
# Upgrading to 6.0
2+
3+
There are some breaking changes you'll need to be aware of when upgrading to v6.
4+
5+
[NHS.UK frontend v10.0.0](https://github.com/nhsuk/nhsuk-frontend/releases/tag/v10.0.0) introduces some breaking changes to file paths, full width buttons on mobile, the header component and others. It also stops Internet Explorer 11 and other older browsers from running NHS.UK frontend JavaScript.
6+
7+
You must read and apply these updates carefully to make sure your service does not break.
8+
9+
## Breaking changes
10+
11+
### Update the JavaScript supported script snippet
12+
13+
You must now use the NHS.UK frontend v10.x feature detection snippet to check for `<script type="module">`. This change enables styling for JavaScript only features in [supported browsers]() only:
14+
15+
```patch
16+
- <body class="js-enabled">
17+
+ <body>
18+
+ <script>document.body.className += ' js-enabled' + ('noModule' in HTMLScriptElement.prototype ? ' nhsuk-frontend-supported' : '');</script>
19+
```
20+
21+
### Update fieldset legend and label size, font weight
22+
23+
To align with NHS.UK frontend, the fieldset legend and label components no longer default to size "XL" when `isPageHeading: true` is set and the `bold` prop has been removed.
24+
25+
You must make the following changes to `labelProps` and `<Label>` components:
26+
27+
- for every `isPageHeading: true` append `size: 'xl'`
28+
- replace `bold: true` with `size: 's'`
29+
30+
```patch
31+
<TextInput
32+
label="Address line 1"
33+
- labelProps={{ isPageHeading: true }}
34+
+ labelProps={{ isPageHeading: true, size: 'xl' }}
35+
autoComplete="address-line1"
36+
/>
37+
<TextInput
38+
label="Address line 2"
39+
- labelProps={{ bold: true }}
40+
+ labelProps={{ size: 's' }}
41+
autoComplete="address-line2"
42+
/>
43+
```
44+
45+
You must make the following changes to `<Fieldset.Legend>` components:
46+
47+
- for every `isPageHeading` append `size="xl"`
48+
49+
```patch
50+
<Fieldset>
51+
- <Fieldset.Legend isPageHeading>What is your address?</Fieldset.Legend>
52+
+ <Fieldset.Legend isPageHeading size="xl">What is your address?</Fieldset.Legend>
53+
<!-- // ... -->
54+
</Fieldset>
55+
```
56+
57+
### Restore visually hidden text for accessibility
58+
59+
For accessibility reasons, it's no longer possible to pass `visuallyHiddenText: false` or override other hidden text for the following:
60+
61+
- [**Breadcrumbs** back link prefix](https://service-manual.nhs.uk/design-system/components/breadcrumbs)
62+
- [**Care card** urgency level](https://service-manual.nhs.uk/design-system/patterns/help-users-decide-when-and-where-to-get-care)
63+
- [**Contents list** links heading](https://service-manual.nhs.uk/design-system/components/contents-list)
64+
- [**Inset text** prefix](https://service-manual.nhs.uk/design-system/components/inset-text)
65+
- [**Warning callout** prefix](https://service-manual.nhs.uk/design-system/components/warning-callout)
66+
67+
Read about other [changes to meet WCAG 2.2](https://service-manual.nhs.uk/design-system/changes-to-design-system-wcag-2-2) on the design system in the NHS digital service manual.
68+
69+
### Check components that conditionally reveal content still work
70+
71+
Previously, conditionally revealing content ([radios](https://service-manual.nhs.uk/design-system/components/radios#conditionally-revealing-content), [checkboxes](https://service-manual.nhs.uk/design-system/components/checkboxes#conditionally-revealing-content)) would not be rendered until their related input was checked.
72+
73+
To align with NHS.UK frontend, conditionally revealing content is now always rendered but remains hidden until revealed. Accessibility issues with missing `aria-controls`, `aria-describedby` or `aria-expanded` are now fixed.
74+
75+
You must check all form components, form validation and error handling that may not expect hidden conditionally revealing content in the HTML.
76+
77+
### Remove unsupported icons
78+
79+
To align with NHS.UK frontend, icons unused by components have been removed:
80+
81+
- `ChevronLeftIcon`
82+
- `ChevronRightIcon`
83+
- `ChevronDownIcon`
84+
- `CloseIcon`
85+
- `EmdashIcon` and `SmallEmdashIcon`
86+
- `MinusIcon`
87+
- `PlusIcon`
88+
89+
### Back link
90+
91+
To align with NHS.UK frontend, we've added an underline to the [back link component](https://service-manual.nhs.uk/design-system/components/back-link). We've also changed the default text from "Go back" to "Back" in all examples.
92+
93+
### Button
94+
95+
To align with NHS.UK frontend, we've updated the [button component](https://service-manual.nhs.uk/design-system/components/buttons) to remove any references to the `nhsuk-button--disabled` class.
96+
97+
Use the [`disabled` HTML boolean attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/disabled) to mark `<button>` elements as being disabled instead.
98+
99+
You must also make the following changes:
100+
101+
- replace `<DefaultButton>` with `<Button>` to render HTML `<button>` elements
102+
- replace `<LinkButton>` with `<Button href="/example">` to render HTML `<a>` elements
103+
- remove the `debounceTimeout` prop when preventing double clicks
104+
105+
### Character count
106+
107+
To align with NHS.UK frontend, we have removed `enum CharacterCountType` and you must make the following changes:
108+
109+
- use the `maxLength` prop for maximum characters only
110+
- use the `maxWords` prop for maximum words only
111+
- rename the `thresholdPercent` prop to `threshold`
112+
- remove the `countType` prop
113+
114+
To count maximum characters:
115+
116+
```patch
117+
- <CharacterCountComponent maxLength={350} countType={CharacterCountType.Characters} textAreaId="example">
118+
+ <CharacterCountComponent maxLength={350} textAreaId="example">
119+
```
120+
121+
To count maximum words:
122+
123+
```patch
124+
- <CharacterCountComponent maxLength={20} countType={CharacterCountType.Words} textAreaId="example">
125+
+ <CharacterCountComponent maxWords={20} textAreaId="example">
126+
```
127+
128+
### Contents list
129+
130+
To align with NHS.UK frontend, the contents list component automatically adds ARIA attributes for the current item. You must make the following changes:
131+
132+
- remove the `ContentsList` component `aria-label` attribute
133+
- remove the `ContentsList.Item` component `aria-current` attribute
134+
135+
```patch
136+
- <ContentsList aria-label="Pages in this guide">
137+
+ <ContentsList>
138+
- <ContentsList.Item current aria-current="page">Example page 1</ContentsList.Item>
139+
- <ContentsList.Item current>Example page 1</ContentsList.Item>
140+
<ContentsList.Item>Example page 2</ContentsList.Item>
141+
<ContentsList.Item>Example page 3</ContentsList.Item>
142+
</ContentsList>
143+
```
144+
145+
### Date input
146+
147+
To align with NHS.UK frontend, the date input component automatically renders its own fieldset, legend and associated ARIA attributes. The custom `autoSelectNext` prop is no longer supported:
148+
149+
```patch
150+
<DateInput
151+
- label="What is your date of birth?"
152+
+ legend="What is your date of birth?"
153+
hint="For example, 15 3 1984"
154+
- autoSelectNext={true}
155+
value={value}
156+
/>
157+
```
158+
159+
The custom `autoSelectNext` prop is no longer supported.
160+
161+
### New header component with account section
162+
163+
The updated header component from NHS.UK frontend v10.x has been added. You will need to make the following changes:
164+
165+
- remove the wrapping `Header.Container` component
166+
- remove the wrapping `Header.Content` component
167+
- remove the automatically created `HeaderComponent.ServiceName` component
168+
- remove the automatically created `Header.NavDropdownMenu` component
169+
- rename the `Header.Nav` component to `Header.Navigation`
170+
- rename the `Header.NavItem` component to `Header.NavigationItem`
171+
172+
```patch
173+
<Header>
174+
- <Header.Container>
175+
- <Header.Logo href="/" />
176+
- <Header.Content>
177+
- <Header.Search />
178+
- </Header.Content>
179+
- </Header.Container>
180+
+ <Header.Logo href="/" />
181+
+ <Header.Search />
182+
- <Header.Nav>
183+
- <Header.NavItem href="#">Example 1</Header.NavItem>
184+
- <Header.NavItem href="#">Example 2</Header.NavItem>
185+
- <Header.NavItem href="#">Example 3</Header.NavItem>
186+
- <Header.NavItem href="#">Example 4</Header.NavItem>
187+
- <Header.NavDropdownMenu />
188+
- </Header.Nav>
189+
+ <Header.Navigation>
190+
+ <Header.NavigationItem href="#">Example 1</Header.NavigationItem>
191+
+ <Header.NavigationItem href="#">Example 2</Header.NavigationItem>
192+
+ <Header.NavigationItem href="#">Example 3</Header.NavigationItem>
193+
+ <Header.NavigationItem href="#">Example 4</Header.NavigationItem>
194+
+ </Header.Navigation>
195+
</Header>
196+
```
197+
198+
### Footer
199+
200+
The updated footer component from NHS.UK frontend v10.x has been added. You will need to make the following changes:
201+
202+
- replace `<Footer.List className="nhsuk-footer__meta">` with `<Header.Meta>`
203+
- nest the `Footer.Copyright` component into `Header.Meta` component
204+
205+
```patch
206+
<Footer>
207+
<Footer.List>
208+
<Footer.ListItem href="#">Item 1</Footer.ListItem>
209+
<Footer.ListItem href="#">Item 2</Footer.ListItem>
210+
<Footer.ListItem href="#">Item 3</Footer.ListItem>
211+
</Footer.List>
212+
213+
- <Footer.List className="nhsuk-footer__meta">
214+
+ <Footer.Meta>
215+
<Footer.ListItem href="#">Meta 1</Footer.ListItem>
216+
<Footer.ListItem href="#">Meta 2</Footer.ListItem>
217+
<Footer.ListItem href="#">Meta 3</Footer.ListItem>
218+
+
219+
+ <Footer.Copyright />
220+
- </Footer.List>
221+
+ </Footer.Meta>
222+
- <Footer.Copyright />
223+
</Footer>
224+
```
225+
226+
### List panel
227+
228+
The list panel component was removed in NHS.UK frontend v6.0.0 and must be replaced with a feature card and nested list:
229+
230+
Before:
231+
232+
```jsx
233+
<Panel label="C" labelProps={{ id: 'C' }} backToTop backToTopLink="#nhsuk-nav-a-z">
234+
<Panel.LinkItem href="/conditions/chest-pain/">Chest pain</Panel.LinkItem>
235+
<Panel.LinkItem href="/conditions/cold-sores/">Cold sore</Panel.LinkItem>
236+
</Panel>
237+
```
238+
239+
After:
240+
241+
```jsx
242+
<Card cardType="feature">
243+
<Card.Content>
244+
<Card.Heading id="C">C</Card.Heading>
245+
<ul className="nhsuk-list nhsuk-list--border">
246+
<li><a href="/conditions/chest-pain/">Chest pain</a></li>
247+
<li><a href="/conditions/cold-sores/">Cold sore</a></li>
248+
</ul>
249+
</Card.Content>
250+
</Card>
251+
252+
<div className="nhsuk-back-to-top">
253+
<a className="nhsuk-back-to-top__link" href="#nhsuk-nav-a-z">
254+
Back to top
255+
</a>
256+
</div>
257+
```
258+
259+
### Radios
260+
261+
To align with NHS.UK frontend, the radios component automatically renders its own fieldset, legend and associated ARIA attributes. You must also rename the `Radios.Radio` component to `Radios.Item` as shown:
262+
263+
```patch
264+
- <Fieldset>
265+
- <Fieldset.Legend>Have you changed your name?</Fieldset.Legend>
266+
- <Radios>
267+
+ <Radios legend="Have you changed your name?">
268+
- <Radios.Radio value="yes">Yes</Radios.Radio>
269+
- <Radios.Radio value="no">No</Radios.Radio>
270+
+ <Radios.Item value="yes">Yes</Radios.Item>
271+
+ <Radios.Item value="no">No</Radios.Item>
272+
</Radios>
273+
- </Fieldset>
274+
```
275+
276+
### Checkboxes
277+
278+
To align with NHS.UK frontend, the checkboxes component automatically renders its own fieldset, legend and associated ARIA attributes. You must also rename the `Checkboxes.Box` component to `Checkboxes.Item` as shown:
279+
280+
```patch
281+
- <Fieldset>
282+
- <Fieldset.Legend>What is your nationality?</Fieldset.Legend>
283+
- <Checkboxes>
284+
+ <Checkboxes legend="What is your nationality?">
285+
- <Checkboxes.Box value="british">British</Checkboxes.Box>
286+
- <Checkboxes.Box value="irish">Irish</Checkboxes.Box>
287+
- <Checkboxes.Box value="other">Citizen of another country</Checkboxes.Box>
288+
+ <Checkboxes.Item value="british">British</Checkboxes.Item>
289+
+ <Checkboxes.Item value="irish">Irish</Checkboxes.Item>
290+
+ <Checkboxes.Item value="other">Citizen of another country</Checkboxes.Item>
291+
</Checkboxes>
292+
- </Fieldset>
293+
```
294+
295+
### Error summary
296+
297+
To align with NHS.UK frontend, the error summary component is automatically alerted to screen readers by focusing itself on render. You will need to make the following changes:
298+
299+
- remove the nested `ErrorSummary.Body` component wrapper
300+
- rename the `ErrorSummary.Item` component to `ErrorSummary.ListItem`
301+
302+
```patch
303+
- </Fieldset>
304+
<ErrorSummary>
305+
<ErrorSummary.Title>There is a problem</ErrorSummary.Title>
306+
- <ErrorSummary.Body>
307+
<ErrorSummary.List>
308+
- <ErrorSummary.Item href="#example-error-1">
309+
+ <ErrorSummary.ListItem href="#example-error-1">
310+
Date of birth must be in the past
311+
- </ErrorSummary.Item>
312+
+ </ErrorSummary.ListItem>
313+
</ErrorSummary.List>
314+
- </ErrorSummary.Body>
315+
</ErrorSummary>
316+
```
317+
318+
### Skip link
319+
320+
To align with NHS.UK frontend, the skip link component focuses the main content rather than the first heading on the page:
321+
322+
```html
323+
<main class="nhsuk-main-wrapper id="maincontent">
324+
<!-- // ... -->
325+
```
326+
327+
For accessibility reasons, you must make the following changes:
328+
329+
- remove the `disableDefaultBehaviour` prop
330+
- remove the `disableHeadingFocus` prop
331+
- remove custom `onClick` handlers
332+
333+
### Warning callout
334+
335+
To align with NHS.UK frontend, the warning callout `WarningCallout.Label` component has been renamed to `WarningCallout.Heading` as shown:
336+
337+
```patch
338+
<WarningCallout>
339+
- <WarningCallout.Label>School, nursery or work</WarningCallout.Label>
340+
+ <WarningCallout.Heading>School, nursery or work</WarningCallout.Heading>
341+
<p>
342+
Stay away from school, nursery or work until all the spots have crusted over. This is
343+
usually 5 days after the spots first appeared.
344+
</p>
345+
</WarningCallout>
346+
```

0 commit comments

Comments
 (0)