Skip to content

Accordion unresponsive when imported asimport Accordion from @mui/material/Accordion via esm.sh  #44649

Open
@schlichtanders

Description

Steps to reproduce

Steps:

  1. Open this link to live example: https://idx.google.com/mui-accordion-3766562 (first time using idx, not sure whether this link works), here stackblitz: https://stackblitz.com/edit/stackblitz-starters-rihbql?file=index.html
  2. See that the Accordion does not work
  3. Change the Accordion import lines inside the script tag to import from the global @mui/material instead, reload, and see that it works.
Here a copy of the standalone html code
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width">
    <meta charset="utf-8">

    <meta name="theme-color" media="(prefers-color-scheme: light)" content="white">
    <meta name="theme-color" media="(prefers-color-scheme: dark)" content="#2a2928">
    <meta name="color-scheme" content="light dark">
    <script type="importmap">
        {
          "imports": {
            "@mui/icons-material": "https://esm.sh/@mui/icons-material@5.15.15?dev&external=react,react-dom&target=es2020&keep-names",
            "@mui/icons-material/": "https://esm.sh/@mui/icons-material@5.15.15&dev&external=react,react-dom&target=es2020&keep-names/",
            "@mui/material": "https://esm.sh/@mui/material@5.15.15?dev&external=react,react-dom&target=es2020",
            "@mui/material/": "https://esm.sh/@mui/material@5.15.15&dev&external=react,react-dom&target=es2020/",
            "htm": "https://esm.sh/htm@3.1.1",
            "htm/preact": "https://esm.sh/htm@3.1.1/preact?external=preact",
            "preact": "https://esm.sh/preact@10.13.2?target=es2020",
            "preact/hooks": "https://esm.sh/preact@10.13.2/hooks?target=es2020",
            "react": "https://esm.sh/preact@10.13.2/compat?target=es2020",
            "react-dom": "https://esm.sh/preact@10.13.2/compat?target=es2020",
            "react/jsx-runtime": "https://esm.sh/preact@10.13.2/jsx-runtime?target=es2020"
          }
        }
    </script>
</head>

<body>

  <div id="app"></div>

  <script type="module">
    // preact to its best - we can create simple html pages which are completely self-containing
    import { render } from 'preact'
    import { html } from 'htm/preact'
    import Accordion from '@mui/material/Accordion'
    import AccordionSummary from '@mui/material/AccordionSummary'
    import AccordionDetails from '@mui/material/AccordionDetails'
    // alternatively, importing it from @mui/material directly works 
    // import {Accordion, AccordionSummary, AccordionDetails} from "@mui/material"
    import ExpandMoreIcon from '@mui/icons-material/ExpandMore'

    export function App() {
      return html`
        <div>
          <${Accordion}
          >
            <${AccordionSummary} 
              expandIcon=${html`<${ExpandMoreIcon} />`}
            >
              hello world
            <//>
            <${AccordionDetails} >
              nice stuff
            <//>
          <//>

          <${Accordion}
          >
            <${AccordionSummary}
              expandIcon=${html`<${ExpandMoreIcon} />`}
            >
              and more
            <//>
            <${AccordionDetails} >
              more stuff
            <//>
          <//>
        </div>  
      `;
    }

    render(html`<${App} />`, document.getElementById('app'));
  </script>
</body>
</html>

Current behavior

Accordion is frozen with the one import style

Expected behavior

Accordion behaves identical on both imports

Context

This uses preact and importmaps via esm.sh, making it possible to create standalone html apps with material ui

Your environment

see context above, especially the importmap in the html file

Search keywords: Accordion, esm.sh, importmaps, preact

Metadata

Labels

bug 🐛Something doesn't workcomponent: accordionThis is the name of the generic UI component, not the React module!package: material-uiSpecific to @mui/material

Projects

  • Status

    Selected

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions