Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[material-ui][Accordion] AccordionDetails is not visible when passing custom component through slotProps.transition #40983

Open
sai6855 opened this issue Feb 7, 2024 · 2 comments
Assignees
Labels
bug 🐛 Something doesn't work component: accordion This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material

Comments

@sai6855
Copy link
Contributor

sai6855 commented Feb 7, 2024

Steps to reproduce

Steps:

  1. Replace below code in this demo and click on 1st accordion
 import * as React from 'react';
import Accordion, { AccordionSlots } from '@mui/material/Accordion';
import AccordionSummary from '@mui/material/AccordionSummary';
import AccordionDetails from '@mui/material/AccordionDetails';
import Typography from '@mui/material/Typography';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import Fade from '@mui/material/Fade';

export default function AccordionTransition() {
  const [expanded, setExpanded] = React.useState(false);

  const handleExpansion = () => {
    setExpanded((prevExpanded) => !prevExpanded);
  };

  return (
    <div>
      <Accordion
        expanded={expanded}
        onChange={handleExpansion}
      
        slotProps={{ transition: { timeout: 400,component:Fade } }}
        sx={{
          '& .MuiAccordion-region': { height: expanded ? 'auto' : 0 },
          '& .MuiAccordionDetails-root': { display: expanded ? 'block' : 'none' },
        }}
      >
        <AccordionSummary
          expandIcon={<ExpandMoreIcon />}
          aria-controls="panel1-content"
          id="panel1-header"
        >
          <Typography>Custom transition using Fade</Typography>
        </AccordionSummary>
        <AccordionDetails>
          <Typography>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
            malesuada lacus ex, sit amet blandit leo lobortis eget.
          </Typography>
        </AccordionDetails>
      </Accordion>
      <Accordion>
        <AccordionSummary
          expandIcon={<ExpandMoreIcon />}
          aria-controls="panel2-content"
          id="panel2-header"
        >
          <Typography>Default transition using Collapse</Typography>
        </AccordionSummary>
        <AccordionDetails>
          <Typography>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
            malesuada lacus ex, sit amet blandit leo lobortis eget.
          </Typography>
        </AccordionDetails>
      </Accordion>
    </div>
  );
}

Current behavior

AccordionDetails is not visible

Expected behavior

AccordionDetails is visible

Context

Opened PR to resolve the issue, but first wanted to check if this is a valid bug.

PR: #40961

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: accordion

@sai6855 sai6855 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Feb 7, 2024
@sai6855 sai6855 changed the title [material-ui][Accordion] AccordionDetails is not visible when passing `` [material-ui][Accordion] AccordionDetails is not visible when passing custom component through slotProps.transition Feb 7, 2024
@sai6855 sai6855 added component: accordion This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material labels Feb 7, 2024
@DiegoAndai
Copy link
Member

Hey, @sai6855! Thanks for catching this. It does seem like a bug 🤔

@DiegoAndai DiegoAndai added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 8, 2024
@Arsil99
Copy link

Arsil99 commented Feb 9, 2024

Hey, @sai6855. I found the solution you should write
this line => slotProps={{ transition: { timeout: 400,component:'Fade' } }}
and it will work :)

just write 'Fade' instead of Fade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: accordion This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants