mui / base-ui

Base UI is an open-source library of accessible, unstyled UI components for React.
MIT License
288 stars 47 forks source link

[collapsible][accordion] Add `keepMounted` prop #807

Open mj12albert opened 2 weeks ago

mj12albert commented 2 weeks ago

Closes https://github.com/mui/base-ui/issues/728

We decided to default keepMounted to false for consistency with other components.

Since hiddenUntilFound requires keepMounted={true} to work, using it will override keepMounted and show a warning in dev mode if both hiddenUntilFound and keepMounted={false} are specified.

mui-bot commented 2 weeks ago

Netlify deploy preview

https://deploy-preview-807--base-ui.netlify.app/

Generated by :no_entry_sign: dangerJS against 798e9a46732c9e6dc9b10fb2c1de2403e4c0b9e1

mj12albert commented 2 weeks ago

@colmtuite @vladmoroz Do you think it's an issue that 2 props are required to use hidden-until-found now?

<Collapsible.Panel hiddenUntilFound keepMounted>
  {/* content */}
</Collapsible.Panel>
vladmoroz commented 2 weeks ago

@mj12albert I think we should always mount the panel when hiddenUntilFound is used, regardless of keepMounted

michaldudak commented 2 weeks ago

If keepMounted is undefined, then yes, we can make hiddenUntilFound make the component always mounted. But when it's explicitly set to false, I'd show a warning (in dev mode only, though).

mj12albert commented 2 weeks ago

Updated ~ would appreciate a review @vladmoroz @michaldudak 🙏