@@ -28,7 +28,7 @@ function Collapsible(props: {
28
28
keepMounted = true ,
29
29
defaultOpen = false ,
30
30
id,
31
- hiddenUntilFound : hiddenUntilFoundProp = false ,
31
+ hiddenUntilFound : hiddenUntilFoundProp = true ,
32
32
} = props ;
33
33
34
34
const [ open , setOpen ] = React . useState ( defaultOpen ) ;
@@ -92,7 +92,7 @@ function Collapsible(props: {
92
92
const panelStyles = getComputedStyle ( element ) ;
93
93
if (
94
94
panelStyles . animationName !== 'none' &&
95
- panelStyles . transitionDelay !== '0s'
95
+ panelStyles . transitionDuration !== '0s'
96
96
) {
97
97
warn ( 'CSS transitions and CSS animations both detected' ) ;
98
98
} else if (
@@ -333,7 +333,7 @@ function Collapsible(props: {
333
333
334
334
setHeight ( panel . scrollHeight ) ;
335
335
336
- if ( ! shouldCancelInitialOpenAnimationRef . current ) {
336
+ if ( ! shouldCancelInitialOpenAnimationRef . current && ! isBeforeMatchRef . current ) {
337
337
panel . style . removeProperty ( 'animation-name' ) ;
338
338
}
339
339
@@ -358,12 +358,7 @@ function Collapsible(props: {
358
358
useEnhancedEffect ( ( ) => {
359
359
const panel = panelRef . current ;
360
360
361
- if (
362
- panel &&
363
- hiddenUntilFoundProp &&
364
- animationTypeRef . current === 'css-transition' &&
365
- isHidden
366
- ) {
361
+ if ( panel && hiddenUntilFoundProp && isHidden ) {
367
362
/**
368
363
* React only supports a boolean for the `hidden` attribute and forces
369
364
* legit string values to booleans so we have to force it back in the DOM
@@ -376,7 +371,9 @@ function Collapsible(props: {
376
371
* to `'until-found'` as they could have different `display` properties:
377
372
* https://github.com/tailwindlabs/tailwindcss/pull/14625
378
373
*/
379
- panel . setAttribute ( 'data-starting-style' , '' ) ;
374
+ if ( animationTypeRef . current === 'css-transition' ) {
375
+ panel . setAttribute ( 'data-starting-style' , '' ) ;
376
+ }
380
377
}
381
378
} , [ hiddenUntilFoundProp , isHidden ] ) ;
382
379
@@ -387,10 +384,7 @@ function Collapsible(props: {
387
384
return undefined ;
388
385
}
389
386
390
- function handleBeforeMatch ( event : Event ) {
391
- // TODO: probably remove this because beforematch isn't cancellable anyway
392
- event . preventDefault ( ) ;
393
-
387
+ function handleBeforeMatch ( ) {
394
388
isBeforeMatchRef . current = true ;
395
389
setOpen ( true ) ;
396
390
}
0 commit comments