Skip to content

Conversation

mj12albert
Copy link
Member

@mj12albert mj12albert commented Mar 10, 2025

Demo: https://deploy-preview-1549--base-ui.netlify.app/experiments/collapsible/transition

Exploring a solution for both #1334 and #1458

Findings:

  • Tailwind v4 defaults started applying display: none !important on [hidden] which we must override in order to measure the node

  • New gotcha: when transitioning multiple properties e.g. opacity and height together, transition-property must list individual properties (transition-property: height, opacity) instead of all solved and not a limitation anymore ✌️

  • Used an AbortController to cancel pending unmounts if the open state changes back to open before the pending unmount actually occurs (which is after the duration of the exit transition). I wonder if CSS animations can be made interruptible like transitions with AbortController.

  • Using element.style.removeProperty('height') leads to huge improvements in the timing/consistency vs element.style.height = '' (or even '0px')

  • There is a weird edge case when keepMounted={false} and the panel is initially closed, when it opens for the first time and only the first time data-starting-style is missing or off by a frame and it needs to be manually set: element.setAttribute('data-starting-style', '')

  • I have followed (at least) the PR section of the contributing guide.

@mj12albert mj12albert added the component: collapsible Changes related to the collapsible component. label Mar 10, 2025
Copy link

netlify bot commented Mar 10, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 5c9a159
🔍 Latest deploy log https://app.netlify.com/sites/base-ui/deploys/67da52a4bd1ead00087df245
😎 Deploy Preview https://deploy-preview-1549--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mj12albert mj12albert force-pushed the fix/collapsible-transitions branch 2 times, most recently from e95ace8 to c677588 Compare March 11, 2025 02:55
[data-demo]:not([data-demo='tailwind']) * {
all: revert-layer;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tailwind v4 preflight contains:

[hidden]:where(:not([hidden="until-found"])) {
  display: none !important;
}

which interferes when we need to set display: block while the panel is still hidden to measure it's rendered size before the browser actually renders the change

Setting !important in our inline styles should be enough as long as they are removed accordingly

@mj12albert mj12albert force-pushed the fix/collapsible-transitions branch 5 times, most recently from deab71c to 9d2d1fb Compare March 12, 2025 07:46
@mj12albert mj12albert force-pushed the fix/collapsible-transitions branch 3 times, most recently from d33ec17 to 277a85d Compare March 18, 2025 11:47
@mj12albert mj12albert force-pushed the fix/collapsible-transitions branch from 277a85d to 00f99b8 Compare March 19, 2025 04:26
@mj12albert mj12albert force-pushed the fix/collapsible-transitions branch from 6febffa to 5c9a159 Compare March 19, 2025 05:14
@mj12albert
Copy link
Member Author

Continues in #1601

@mj12albert mj12albert closed this Mar 24, 2025
@mj12albert mj12albert deleted the fix/collapsible-transitions branch March 24, 2025 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: collapsible Changes related to the collapsible component.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant