From 88e94d9f75497a5d84f7cb9fb08c23bdbd747713 Mon Sep 17 00:00:00 2001
From: Ryo Matsukawa <76232929+ryo-manba@users.noreply.github.com>
Date: Tue, 9 Jan 2024 22:48:43 +0900
Subject: [PATCH 1/2] fix: remove dividers from hidden accordion items
---
.../accordion/__tests__/accordion.test.tsx | 19 +++++++++++++++++++
.../components/accordion/src/accordion.tsx | 5 ++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/packages/components/accordion/__tests__/accordion.test.tsx b/packages/components/accordion/__tests__/accordion.test.tsx
index 3c5bab131c..1571961db0 100644
--- a/packages/components/accordion/__tests__/accordion.test.tsx
+++ b/packages/components/accordion/__tests__/accordion.test.tsx
@@ -68,6 +68,25 @@ describe("Accordion", () => {
expect(wrapper.getAllByRole("button")[0]).toBeDisabled();
});
+ it("should hide the accordion item when the hidden prop is set", () => {
+ const wrapper = render(
+
+
+ Accordion Item 1 description
+
+
+ Accordion Item 2 description
+
+
+ Accordion Item 3 description
+
+ ,
+ );
+
+ expect(wrapper.getAllByRole("button")).toHaveLength(2);
+ expect(wrapper.getAllByRole("separator")).toHaveLength(1);
+ });
+
it("should expand the accordion item when clicked", async () => {
const wrapper = render(
diff --git a/packages/components/accordion/src/accordion.tsx b/packages/components/accordion/src/accordion.tsx
index 0f20477343..47d7f380f2 100644
--- a/packages/components/accordion/src/accordion.tsx
+++ b/packages/components/accordion/src/accordion.tsx
@@ -41,7 +41,10 @@ const AccordionGroup = forwardRef<"div", AccordionProps>((props, ref) => {
{...item.props}
classNames={classNames}
/>
- {!isSplitted && showDivider && index < state.collection.size - 1 && }
+ {!item.props.hidden &&
+ !isSplitted &&
+ showDivider &&
+ index < state.collection.size - 1 && }
);
});
From 1f274f46de251042b716ccffdd83c4dc88b5fcbf Mon Sep 17 00:00:00 2001
From: Ryo Matsukawa <76232929+ryo-manba@users.noreply.github.com>
Date: Tue, 5 Mar 2024 22:06:23 +0900
Subject: [PATCH 2/2] Create slimy-panthers-swim.md
---
.changeset/slimy-panthers-swim.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 .changeset/slimy-panthers-swim.md
diff --git a/.changeset/slimy-panthers-swim.md b/.changeset/slimy-panthers-swim.md
new file mode 100644
index 0000000000..da85c3f1b8
--- /dev/null
+++ b/.changeset/slimy-panthers-swim.md
@@ -0,0 +1,5 @@
+---
+"@nextui-org/accordion": patch
+---
+
+fixed remove dividers from hidden accordion items (#2210)