Skip to content

Commit 00f99b8

Browse files
committed
CSS animation fixes
1 parent f8d0147 commit 00f99b8

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

docs/src/app/(private)/experiments/collapsible/animation.module.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
.Root {
5353
--width: 320px;
54-
--duration: 5000ms;
54+
--duration: 900ms;
5555

5656
width: var(--width);
5757

docs/src/app/(private)/experiments/collapsible/new.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
useEnhancedEffect,
55
useTransitionStatus,
66
} from '@base-ui-components/react/utils';
7-
import classes from './transition.module.css';
7+
import classes from './animation.module.css';
88
import { ExpandMoreIcon } from './_icons';
99

1010
import { useAnimationsFinished } from '../../../../../../packages/react/src/utils/useAnimationsFinished';
@@ -28,7 +28,7 @@ function Collapsible(props: {
2828
keepMounted = true,
2929
defaultOpen = false,
3030
id,
31-
hiddenUntilFound: hiddenUntilFoundProp = true,
31+
hiddenUntilFound: hiddenUntilFoundProp = false,
3232
} = props;
3333

3434
const [open, setOpen] = React.useState(defaultOpen);
@@ -329,7 +329,7 @@ function Collapsible(props: {
329329
latestAnimationNameRef.current =
330330
panel.style.animationName || latestAnimationNameRef.current;
331331

332-
panel.style.animationName = 'none';
332+
panel.style.setProperty('animation-name', 'none');
333333

334334
setHeight(panel.scrollHeight);
335335

@@ -339,11 +339,13 @@ function Collapsible(props: {
339339

340340
if (open) {
341341
setMounted(true);
342+
setVisible(true);
343+
} else {
344+
runOnceAnimationsFinish(() => {
345+
setMounted(false);
346+
setVisible(false);
347+
});
342348
}
343-
344-
runOnceAnimationsFinish(() => {
345-
setVisible(open);
346-
});
347349
}, [open, visible, runOnceAnimationsFinish, setMounted]);
348350

349351
useOnMount(() => {

0 commit comments

Comments
 (0)