Skip to content

[Accordion][Collapsible] Simplify shouldRender condition in AccordionPanel and CollapsiblePanel#4338

Merged
atomiks merged 4 commits intomui:masterfrom
sai6855:ref-mounted
Mar 20, 2026
Merged

[Accordion][Collapsible] Simplify shouldRender condition in AccordionPanel and CollapsiblePanel#4338
atomiks merged 4 commits intomui:masterfrom
sai6855:ref-mounted

Conversation

@sai6855
Copy link
Member

@sai6855 sai6855 commented Mar 15, 2026

Simplify shouldRender condition in AccordionPanel and CollapsiblePanel

Simplify shouldRender condition in AccordionPanel and CollapsiblePanel
Copilot AI review requested due to automatic review settings March 15, 2026 15:42
@sai6855 sai6855 changed the title [Accordion][Collapsible] [Accordion][Collapsible] Simplify shouldRender condition in AccordionPanel and CollapsiblePanel Mar 15, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR simplifies the render gating logic for AccordionPanel and CollapsiblePanel by removing a redundant !keepMounted check while keeping the same behavior for when panels should stay mounted or be rendered.

Changes:

  • Simplified shouldRender in CollapsiblePanel to keepMounted || hiddenUntilFound || mounted.
  • Simplified shouldRender in AccordionPanel to keepMounted || hiddenUntilFound || mounted.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/react/src/collapsible/panel/CollapsiblePanel.tsx Removes redundant boolean logic in the shouldRender condition without changing behavior.
packages/react/src/accordion/panel/AccordionPanel.tsx Mirrors the same simplification for accordion panels to keep the logic consistent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 15, 2026

commit: 9758383

});

const shouldRender = keepMounted || hiddenUntilFound || (!keepMounted && mounted);
const shouldRender = keepMounted || hiddenUntilFound || mounted;
Copy link
Member Author

Choose a reason for hiding this comment

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

When shouldRender is evaluated, if keepMounted were true, the expression would already short-circuit. So !keepMounted is always true by the time the third operand is reached, making it redundant.

@mui-bot
Copy link

mui-bot commented Mar 15, 2026

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react ▼-8B(0.00%) ▼-10B(-0.01%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify
Copy link

netlify bot commented Mar 15, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 9758383
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69bc92ab017aef00088eccf5
😎 Deploy Preview https://deploy-preview-4338--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 project configuration.

@sai6855 sai6855 added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. component: collapsible Changes related to the collapsible component. component: accordion Changes related to the accordion component. labels Mar 16, 2026
@sai6855 sai6855 requested review from LukasTy and mj12albert March 16, 2026 14:05
@atomiks atomiks merged commit 4133d56 into mui:master Mar 20, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: accordion Changes related to the accordion component. component: collapsible Changes related to the collapsible component. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants