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

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

Open
schlichtanders opened this issue Dec 4, 2024 · 3 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

@schlichtanders
Copy link

schlichtanders commented Dec 4, 2024

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/[email protected]?dev&external=react,react-dom&target=es2020&keep-names",
            "@mui/icons-material/": "https://esm.sh/@mui/[email protected]&dev&external=react,react-dom&target=es2020&keep-names/",
            "@mui/material": "https://esm.sh/@mui/[email protected]?dev&external=react,react-dom&target=es2020",
            "@mui/material/": "https://esm.sh/@mui/[email protected]&dev&external=react,react-dom&target=es2020/",
            "htm": "https://esm.sh/[email protected]",
            "htm/preact": "https://esm.sh/[email protected]/preact?external=preact",
            "preact": "https://esm.sh/[email protected]?target=es2020",
            "preact/hooks": "https://esm.sh/[email protected]/hooks?target=es2020",
            "react": "https://esm.sh/[email protected]/compat?target=es2020",
            "react-dom": "https://esm.sh/[email protected]/compat?target=es2020",
            "react/jsx-runtime": "https://esm.sh/[email protected]/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

@schlichtanders schlichtanders added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 4, 2024
@mj12albert
Copy link
Member

@schlichtanders Hey thanks for reporting this, your link is auth protected though, is this reproducible in CodeSandbox or StackBlitz?

BTW is it just Accordion or all components 🤔

@mj12albert mj12albert added status: waiting for author Issue with insufficient information package: material-ui Specific to @mui/material and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 4, 2024
@mj12albert mj12albert changed the title Accordion component is unresponsive when imported via @mui/material/Accordion Accordion unresponsive when imported asimport Accordion from @mui/material/Accordion via esm.sh Dec 4, 2024
@mj12albert
Copy link
Member

Possibly related to #44509

@schlichtanders
Copy link
Author

I only encountered this with Accordion so far, not with other components

here a stackblitz version: https://stackblitz.com/edit/stackblitz-starters-rihbql?file=index.html

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Dec 4, 2024
@zannager zannager added the component: accordion This is the name of the generic UI component, not the React module! label Dec 4, 2024
@DiegoAndai DiegoAndai self-assigned this Dec 5, 2024
@DiegoAndai DiegoAndai moved this to Selected in Material UI Dec 5, 2024
@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 Dec 13, 2024
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
Status: Selected
Development

No branches or pull requests

4 participants