Skip to content

Commit dc58cd6

Browse files
authored
fix: Accordion release audit (#7369)
* accordion release audit * yarn.lock * lint * yarn.lock * docs updates * update keywords * update S2 Migration guide * update deps * update migration docs
1 parent d8161f6 commit dc58cd6

File tree

15 files changed

+37
-30
lines changed

15 files changed

+37
-30
lines changed

.storybook-s2/docs/Migrating.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ export function Migrating() {
3434
<li className={style({font: 'body', marginY: 8})}>Update <Link href="https://react-spectrum.adobe.com/react-spectrum/styling.html#style-props">style props</Link> to use the <Link href="?path=/docs/style-macro--docs">style macro</Link> instead. See the 'Style props' section below</li>
3535
</ul>
3636

37+
<H3>Accordion</H3>
38+
<ul className="sb-unstyled">
39+
<li className={style({font: 'body', marginY: 8})}>Update <Code>Item</Code> to be <Code>Disclosure</Code>. <Code>Disclosure</Code> should now consist of two children: <Code>DisclosureTitle</Code> and <Code>DisclosurePanel</Code>. Note that you can now add interactive elements inside the header and adjacent to the title by using the <Code>DisclosureHeader</Code> component with the <Code>DisclosureTitle</Code> and interactive elements inside.</li>
40+
<li className={style({font: 'body', marginY: 8})}>Update <Code>Item</Code>'s title prop to be a child of <Code>DisclosureTitle</Code></li>
41+
<li className={style({font: 'body', marginY: 8})}>Update children of <Code>Item</Code> to be children of <Code>DisclosurePanel</Code></li>
42+
<li className={style({font: 'body', marginY: 8})}>Update <Code>key</Code> to be <Code>id</Code> (and keep <Code>key</Code> if rendered inside <Code>array.map</Code>)</li>
43+
<li className={style({font: 'body', marginY: 8})}>Remove <Code>disabledKeys</Code> and add <Code>isDisabled</Code> to individual <Code>Disclosure</Code> components</li>
44+
<li className={style({font: 'body', marginY: 8})}>Add <Code>allowsMultipleExpanded</Code> to allow multiple <Code>Disclosure</Code> components to be expanded at once (previously default behavior)</li>
45+
</ul>
46+
3747
<H3>ActionButton</H3>
3848
<P>No updates needed.</P>
3949

packages/@react-aria/accordion/src/useAccordion.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,24 @@ import {TreeState} from '@react-stately/tree';
1818
import {useButton} from '@react-aria/button';
1919
import {useSelectableItem, useSelectableList} from '@react-aria/selection';
2020

21+
/**
22+
* @deprecated Use useDisclosure from `@react-aria/disclosure` instead.
23+
*/
2124
export interface AccordionAria {
2225
/** Props for the accordion container element. */
2326
accordionProps: DOMAttributes
2427
}
2528

29+
/**
30+
* @deprecated Use useDisclosure from `@react-aria/disclosure` instead.
31+
*/
2632
export interface AccordionItemAriaProps<T> {
2733
item: Node<T>
2834
}
2935

36+
/**
37+
* @deprecated Use useDisclosure from `@react-aria/disclosure` instead.
38+
*/
3039
export interface AccordionItemAria {
3140
/** Props for the accordion item button. */
3241
buttonProps: ButtonHTMLAttributes<HTMLElement>,

packages/@react-aria/disclosure/package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,10 @@
2222
"url": "https://github.com/adobe/react-spectrum"
2323
},
2424
"dependencies": {
25-
"@react-aria/button": "^3.10.1",
26-
"@react-aria/selection": "^3.20.1",
2725
"@react-aria/ssr": "^3.9.6",
2826
"@react-aria/utils": "^3.25.3",
2927
"@react-stately/disclosure": "3.0.0-alpha.0",
30-
"@react-stately/toggle": "^3.7.8",
31-
"@react-stately/tree": "^3.8.5",
3228
"@react-types/button": "^3.10.0",
33-
"@react-types/shared": "^3.25.0",
3429
"@swc/helpers": "^0.5.0"
3530
},
3631
"peerDependencies": {

packages/@react-aria/disclosure/src/useDisclosure.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ export interface DisclosureAria {
3939
* Provides the behavior and accessibility implementation for a disclosure component.
4040
* @param props - Props for the disclosure.
4141
* @param state - State for the disclosure, as returned by `useDisclosureState`.
42-
* @param ref - A ref for the disclosure content.
42+
* @param ref - A ref for the disclosure panel.
4343
*/
4444
export function useDisclosure(props: AriaDisclosureProps, state: DisclosureState, ref: RefObject<Element | null>): DisclosureAria {
4545
let {
4646
isDisabled
4747
} = props;
4848
let triggerId = useId();
49-
let contentId = useId();
49+
let panelId = useId();
5050
let isSSR = useIsSSR();
5151
let supportsBeforeMatch = !isSSR && 'onbeforematch' in document.body;
5252

@@ -95,7 +95,7 @@ export function useDisclosure(props: AriaDisclosureProps, state: DisclosureState
9595
buttonProps: {
9696
id: triggerId,
9797
'aria-expanded': state.isExpanded,
98-
'aria-controls': contentId,
98+
'aria-controls': panelId,
9999
onPress: (e) => {
100100
if (!isDisabled && e.pointerType !== 'keyboard') {
101101
state.toggle();
@@ -109,7 +109,7 @@ export function useDisclosure(props: AriaDisclosureProps, state: DisclosureState
109109
}
110110
},
111111
panelProps: {
112-
id: contentId,
112+
id: panelId,
113113
// This can be overridden at the panel element level.
114114
role: 'group',
115115
'aria-labelledby': triggerId,

packages/@react-spectrum/accordion/src/Accordion.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export {_Accordion as Accordion};
140140
const _Disclosure = forwardRef(Disclosure) as (props: SpectrumDisclosureProps & {ref?: DOMRef<HTMLDivElement>}) => ReturnType<typeof Disclosure>;
141141
export {_Disclosure as Disclosure};
142142

143-
/** The panel that contains the content of an disclosure. */
143+
/** The panel that contains the content of the disclosure. */
144144
const _DisclosurePanel = forwardRef(DisclosurePanel) as (props: SpectrumDisclosurePanelProps & {ref?: DOMRef<HTMLDivElement>}) => ReturnType<typeof DisclosurePanel>;
145145
export {_DisclosurePanel as DisclosurePanel};
146146

packages/dev/docs/pages/react-aria/components.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ order: 5
405405
<ExampleCard
406406
url="DisclosureGroup.html"
407407
title="DisclosureGroup"
408-
description="A disclosure group is a grouping of related disclosures, sometimes called an Accordion.">
408+
description="A disclosure group is a grouping of related disclosures, sometimes called an accordion.">
409409
<DisclosureGroup />
410410
</ExampleCard>
411411

packages/react-aria-components/docs/Disclosure.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Anatomy from './DisclosureAnatomy.svg';
2121

2222
---
2323
category: Navigation
24-
keywords: [disclosure, collapse, expand, aria]
24+
keywords: [disclosure, collapse, expand, aria, accordion]
2525
type: component
2626
preRelease: alpha
2727
---
@@ -103,7 +103,7 @@ import {Disclosure, Button, DisclosurePanel, Heading} from 'react-aria-component
103103

104104
## Features
105105

106-
Disclosures can be built with the [&lt;details&gt;](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details) and [&lt;summary&gt;](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary) HTML element, but this can be difficult to style especially when adding adjacent interactive elements, like buttons, to the disclosure's heading. `Disclosure` helps achieve accessible disclosures implemented with the correct ARIA pattern while making custom styling easy.
106+
Disclosures can be built with the [&lt;details&gt;](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details) and [&lt;summary&gt;](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary) HTML elements, but this can be difficult to style, especially when adding adjacent interactive elements, like buttons, to the disclosure's heading. `Disclosure` helps achieve accessible disclosures implemented with the correct ARIA pattern while making custom styling easy.
107107

108108
* **Flexible** - Structured such that it can be used standalone or combined with other disclosures to form a `DisclosureGroup`
109109
* **Keyboard Interaction** - When focused, a disclosure's visibility can be toggled with either the <Keyboard>Enter</Keyboard> or <Keyboard>Space</Keyboard> key, and the appropriate ARIA attributes are automatically applied.
@@ -171,7 +171,7 @@ function MyDisclosure({title, children, ...props}: MyDisclosureProps) {
171171
An uncontrolled Disclosure can be expanded by default using the `defaultExpanded` prop.
172172

173173
```tsx example
174-
<MyDisclosure title="Download, Install, and Set Up" defaultExpanded >
174+
<MyDisclosure title="Download, Install, and Set Up" defaultExpanded>
175175
Instructions on how to download, install, and set up
176176
</MyDisclosure>
177177
```
@@ -183,7 +183,7 @@ function ControlledExpanded() {
183183
let [isExpanded, setIsExpanded] = React.useState(true);
184184

185185
return (
186-
<MyDisclosure title="Download, Install, and Set Up" isExpanded={isExpanded} onExpandedChange={setIsExpanded} >
186+
<MyDisclosure title="Download, Install, and Set Up" isExpanded={isExpanded} onExpandedChange={setIsExpanded}>
187187
Instructions on how to download, install, and set up
188188
</MyDisclosure>
189189
)
@@ -198,7 +198,7 @@ function ControlledExpanded() {
198198
A Disclosure can be disabled using the `isDisabled` prop.
199199

200200
```tsx example
201-
<MyDisclosure title="Introduction to Knitting" isDisabled >
201+
<MyDisclosure title="Introduction to Knitting" isDisabled>
202202
Details about knitting here
203203
</MyDisclosure>
204204
```

packages/react-aria-components/docs/DisclosureGroup.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ import {DisclosureGroup, Disclosure, Button, DisclosurePanel, Heading} from 'rea
8282

8383
## Features
8484

85-
Disclosure groups can be built by combing multiple disclosures built in HTML with the [&lt;details&gt;](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details) and [&lt;summary&gt;](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary) HTML element, but this can be difficult to style especially when adding adjacent interactive elements, like buttons, to the disclosure's heading. `DisclosureGroup` helps achieve accessible disclosures implemented with the correct ARIA pattern while making custom styling easy.
85+
Disclosure groups can be built by combining multiple disclosures built in HTML with the [&lt;details&gt;](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details) and [&lt;summary&gt;](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary) HTML elements, but this can be difficult to style, especially when adding adjacent interactive elements, like buttons, to the disclosure's heading. `DisclosureGroup` helps achieve accessible disclosures implemented with the correct ARIA pattern while making custom styling easy.
8686

8787
* **Accessible** - Disclosure group is exposed to assistive technology via ARIA. Uses hidden="until-found" in supported browsers, enabling find-in-page search support and improved search engine visibility for collapsed content.
8888
* **Styleable** - Disclosures include builtin states for styling such as keyboard focus, disabled, and expanded states.

packages/react-aria-components/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"dependencies": {
4040
"@internationalized/date": "^3.5.6",
4141
"@internationalized/string": "^3.2.4",
42-
"@react-aria/accordion": "3.0.0-alpha.35",
4342
"@react-aria/collections": "3.0.0-alpha.5",
4443
"@react-aria/color": "^3.0.1",
4544
"@react-aria/disclosure": "3.0.0-alpha.1",

packages/react-aria-components/src/Disclosure.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function DisclosureGroup(props: DisclosureGroupProps, ref: ForwardedRef<HTMLDivE
6363
}
6464

6565
/**
66-
* A DisclosureGroup is a grouping of related disclosures, sometimes called an Accordion.
66+
* A DisclosureGroup is a grouping of related disclosures, sometimes called an accordion.
6767
* It supports both single and multiple expanded items.
6868
*/
6969
const _DisclosureGroup = forwardRef(DisclosureGroup);

0 commit comments

Comments
 (0)