Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit cd91622

Browse files
Anton Bilovusboilund
authored andcommitted
fix(expandableList): make accordion property optional
1 parent 3374609 commit cd91622

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/core/src/ExpandableList/ExpandableListItem.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface ExpandableListItemProps extends BaseProps {
3434
readonly expandedItems: ReadonlyArray<string>
3535
readonly setExpandedItems: Dispatch<SetStateAction<ReadonlyArray<string>>>
3636
readonly isNestedItem: boolean
37-
readonly isAccordion: boolean
37+
readonly accordion?: boolean
3838
}
3939

4040
/**
@@ -51,7 +51,7 @@ export const ExpandableListItem: React.VFC<ExpandableListItemProps> = ({
5151
expandedItems,
5252
setExpandedItems,
5353
isNestedItem,
54-
isAccordion,
54+
accordion = false,
5555
...props
5656
}) => {
5757
const { id, label, icon, selected = false, onClick, items } = item
@@ -63,7 +63,7 @@ export const ExpandableListItem: React.VFC<ExpandableListItemProps> = ({
6363
if (expandedItems.includes(itemId)) {
6464
// Close the expanded item
6565
nextExpandedItems = expandedItems.filter(i => i !== itemId)
66-
} else if (isAccordion) {
66+
} else if (accordion) {
6767
// Only add one expanded item when accordion
6868
nextExpandedItems = [id]
6969
} else {
@@ -73,7 +73,7 @@ export const ExpandableListItem: React.VFC<ExpandableListItemProps> = ({
7373

7474
setExpandedItems(nextExpandedItems)
7575
})(id),
76-
[expandedItems, id, isAccordion, setExpandedItems]
76+
[expandedItems, id, accordion, setExpandedItems]
7777
)
7878
const hasChildren = items !== undefined
7979
const onItemClick = hasChildren ? onChildClick : onClick
@@ -105,7 +105,7 @@ export const ExpandableListItem: React.VFC<ExpandableListItemProps> = ({
105105
expandedItems={expandedItems}
106106
setExpandedItems={setExpandedItems}
107107
isNestedItem={true}
108-
isAccordion={isAccordion}
108+
accordion={accordion}
109109
/>
110110
))}
111111
</ExpandableListContainer>

packages/core/src/ExpandableList/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const ExpandableList: React.VFC<ExpandableListProps> = ({
4242
item={item}
4343
expandedItems={expandedItems}
4444
setExpandedItems={setExpandedItems}
45-
isAccordion={accordion === true}
45+
accordion={accordion}
4646
isNestedItem={false}
4747
/>
4848
))}

0 commit comments

Comments
 (0)