Skip to content

Commit

Permalink
feat(controlledAccordions): supports toggles, disabled panels
Browse files Browse the repository at this point in the history
  • Loading branch information
2nikhiltom committed Feb 27, 2024
1 parent 07f8651 commit c6b4187
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/react/src/components/Accordion/Accordion.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ export const Controlled = () => {
const [expandAll, setExpandAll] = React.useState(false);
return (
<>
<Button onClick={() => setExpandAll(true)}>Click to expand all</Button>
<Button
onClick={() => {
expandAll === true ? setExpandAll(1) : setExpandAll(true);
}}>
Click to expand all
</Button>
<Button
onClick={() => {
expandAll || expandAll === null
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Accordion/AccordionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function AccordionItem({
const prefix = usePrefix();
const className = cx({
[`${prefix}--accordion__item`]: true,
[`${prefix}--accordion__item--active`]: isOpen,
[`${prefix}--accordion__item--active`]: isOpen && !disabled,
[`${prefix}--accordion__item--disabled`]: disabled,
[customClassName]: !!customClassName,
});
Expand Down

0 comments on commit c6b4187

Please sign in to comment.