Skip to content

Commit 3355960

Browse files
Fix ToggeableLinkItem display (#3744)
Co-authored-by: Zeno Kapitein <zeno@gitbook.io>
1 parent c32d449 commit 3355960

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

.changeset/quiet-icons-deny.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'gitbook': patch
3+
---
4+
5+
Fix ToggeableLinkItem display

packages/gitbook/src/components/TableOfContents/ToggleableLinkItem.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import { Icon } from '@gitbook/icons';
4-
import { motion } from 'motion/react';
4+
import { AnimatePresence, motion } from 'motion/react';
55
import React, { useRef } from 'react';
66

77
import { tcls } from '@/lib/tailwind';
@@ -180,14 +180,10 @@ function Toggler(props: {
180180
const show = {
181181
opacity: 1,
182182
height: 'auto',
183-
display: 'inherit',
184183
};
185184
const hide = {
186185
opacity: 0,
187186
height: 0,
188-
transitionEnd: {
189-
display: 'none',
190-
},
191187
};
192188

193189
function Descendants(props: {
@@ -196,12 +192,17 @@ function Descendants(props: {
196192
}) {
197193
const { isVisible, children } = props;
198194
return (
199-
<motion.div
200-
animate={isVisible ? show : hide}
201-
initial={isVisible ? show : hide}
202-
style={{ overflow: 'hidden' }}
203-
>
204-
{children}
205-
</motion.div>
195+
<AnimatePresence>
196+
{isVisible ? (
197+
<motion.div
198+
initial={hide}
199+
animate={show}
200+
exit={hide}
201+
className="flex flex-col overflow-hidden"
202+
>
203+
{children}
204+
</motion.div>
205+
) : null}
206+
</AnimatePresence>
206207
);
207208
}

0 commit comments

Comments
 (0)