Skip to content

Commit 02a3f9b

Browse files
author
Matthew Holloway
committed
RAA 5, React 18
1 parent 47b5d89 commit 02a3f9b

7 files changed

+2436
-1982
lines changed

CHANGELOG.md

+29
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,35 @@
33
> All notable changes to this project are documented in this file. This project
44
> adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
55
6+
## [[v5.0.0]](https://github.com/springload/react-accessible-accordion/releases/tag/v5.0.0)
7+
8+
React Accessible Accordion now supports React 18 with its out-of-order streaming
9+
feature.
10+
11+
The new out-of-order streaming feature required using React 18's
12+
[`useId`](https://reactjs.org/blog/2022/03/29/react-v18.html#useid) hook. This
13+
affects the DOM ids that RAA generates, changing from `accordion__heading-raa-0`
14+
(React 16 and 17) to `accordion__heading-:r0:` (React 18). Although this change
15+
shouldn't affect most users, if you have any code that selects ids with DOM APIs
16+
such as `document.querySelector()` then the `:` characters will need escaping
17+
with `\\` eg. `document.querySelector('#accordion__heading-\\:r0\\:')`.
18+
19+
When using older versions of React 16 or 17 the same DOM ids will be generated.
20+
21+
Because of this change in behaviour this is a major version upgrade.
22+
23+
## [[v4.0.0]](https://github.com/springload/react-accessible-accordion/releases/tag/v4.0.0)
24+
25+
Making `role="region"` optional on panels.
26+
27+
The new behaviour has no `role="region"` by default, and developers can opt-in
28+
using the `region` prop as `<AccordionItemPanel region>`.
29+
30+
The previous behaviour had every panel as a `role="region"` which created an
31+
excessive amount of regions for the screen reader.
32+
33+
Because of this change in behaviour this is a major version upgrade.
34+
635
## [[v3.3.0]](https://github.com/springload/react-accessible-accordion/releases/tag/v3.3.0)
736

837
### Changed

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ to get in touch via our
207207
208208
## FAQs
209209
210+
### React 18?
211+
212+
RAA supports React 18, and the new out-of-order streaming feature. See the
213+
CHANGELOG for details.
214+
210215
### Which design patterns does this component aim to solve?
211216
212217
Those described by the WAI ARIA spec's description of an 'accordion':
@@ -225,8 +230,8 @@ description, as written above. By "accordion-like", we mean components which
225230
have collapsible items but require bespoke interactive mechanisms in order to
226231
expand, collapse and 'disable' them. This includes (but is not limited to)
227232
multi-step forms, like those seen in many cart/checkout flows, which we believe
228-
require (other) complex markup in order to be considered 'accessible'.
229-
This also includes disclosure widgets.
233+
require (other) complex markup in order to be considered 'accessible'. This also
234+
includes disclosure widgets.
230235
231236
### How do I disable an item?
232237

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@
8989
"@babel/preset-env": "^7.4.5",
9090
"@babel/preset-react": "^7.0.0",
9191
"@babel/preset-typescript": "^7.1.0",
92-
"@testing-library/react": "^8.0.4",
92+
"@testing-library/react": "^13.1.1",
9393
"@types/jest": "^24.0.15",
94-
"@types/react": "^16.8.22",
95-
"@types/react-dom": "^16.8.4",
94+
"@types/react": "^18.0.5",
95+
"@types/react-dom": "^18.0.1",
9696
"@types/react-syntax-highlighter": "^11.0.4",
97-
"@types/react-test-renderer": "^16.8.2",
97+
"@types/react-test-renderer": "^18.0.0",
9898
"@types/uuid": "^3.4.4",
9999
"@typescript-eslint/eslint-plugin": "^3.6.0",
100100
"@typescript-eslint/parser": "^3.6.0",

src/components/AccordionItemButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ type WrapperProps = Pick<
9191
Exclude<keyof DivAttributes, keyof InjectedButtonAttributes>
9292
>;
9393

94-
const AccordionItemButtonWrapper: React.SFC<WrapperProps> = (
94+
const AccordionItemButtonWrapper: React.FC<WrapperProps> = (
9595
props: WrapperProps,
9696
): JSX.Element => (
9797
<ItemConsumer>

src/components/AccordionItemHeading.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ type WrapperProps = Pick<
7171
Exclude<keyof DivAttributes, keyof InjectedHeadingAttributes>
7272
>;
7373

74-
const AccordionItemHeadingWrapper: React.SFC<DivAttributes> = (
74+
const AccordionItemHeadingWrapper: React.FC<DivAttributes> = (
7575
props: WrapperProps,
7676
): JSX.Element => (
7777
<ItemConsumer>

src/components/AccordionItemPanel.spec.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ describe('AccordionItem', () => {
7979
</Accordion>,
8080
);
8181
expect(
82-
getByRole('region').getAttribute('aria-labelledby'),
82+
getByRole('region', { hidden: true }).getAttribute(
83+
'aria-labelledby',
84+
),
8385
).toBeTruthy();
8486
});
8587

@@ -101,7 +103,9 @@ describe('AccordionItem', () => {
101103
const { getByText, queryByRole } = render(
102104
<Accordion>
103105
<AccordionItem>
104-
<AccordionItemPanel region={false}>Hello World</AccordionItemPanel>
106+
<AccordionItemPanel region={false}>
107+
Hello World
108+
</AccordionItemPanel>
105109
</AccordionItem>
106110
</Accordion>,
107111
);

0 commit comments

Comments
 (0)