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

[studio] Unable to load styled-components styles in canvas #3643

Open
Mil4n0r opened this issue Jun 6, 2024 · 3 comments
Open

[studio] Unable to load styled-components styles in canvas #3643

Mil4n0r opened this issue Jun 6, 2024 · 3 comments
Labels
scope: toolpad-studio Abbreviated to "studio" status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@Mil4n0r
Copy link

Mil4n0r commented Jun 6, 2024

Steps to reproduce

Link to live example: (required)

Steps:

  1. Use a mui-toolpad version equal or higher than 0.1.54
  2. Add a custom component from another library that uses styled-components to toolpadComponents.tsx, ComponentCatalogItem and toolpad-studio-components/src (using createBuiltin).
  3. Launch toolpad-studio in dev mode:
pnpm run dev
pnpm toolpad-studio dev toolpad-studio --dev
  1. When in Canvas mode, the custom component will be displayed as a default HTML element. However, when going into the preview, it will display properly.

Current behavior

The custom component is displayed with no styles in the canvas.

Expected behavior

I would expect the custom component to be displayed in the canvas with the proper styles.

Context

This happens after the change that made EXPERIMENTAL_INLINE_CANVAS be the default behavior. I am not entirely sure what it changes. #3370. In previous versions it loaded as expected.

I wonder if there is any known workaround to make custom components that use styled-components to load their styles as expected.

Your environment

npx @mui/envinfo
System:
    OS: Windows 11 10.0.22631
  Binaries:
    Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.3.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.15.8 - ~\AppData\Local\pnpm\pnpm.CMD
  Browsers:
    Chrome: Not Found
    Edge: Chromium (123.0.2420.97) 
  npmPackages:
    @mui/internal-docs-utils: 1.0.7 => 1.0.7 
    @mui/internal-markdown: 1.0.4 => 1.0.4 
    @mui/internal-scripts: 1.0.8 => 1.0.8 
    @mui/monorepo: github:mui/material-ui#a3fdc9f9682b57a6059792634863e39f322cef8d => 6.0.0-alpha.8 
    @mui/x-charts: 7.6.1 => 7.6.1 
    typescript: 5.4.5 => 5.4.5 

Search keywords: styled-components canvas

@Mil4n0r Mil4n0r added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jun 6, 2024
@Janpot
Copy link
Member

Janpot commented Jun 6, 2024

  1. Add a custom component from another library that uses styled-components to toolpadComponents.tsx, ComponentCatalogItem and toolpad-studio-components/src (using createBuiltin).

Am I understanding correctly that you are using a fork of Toolpad and are trying to add components in the builtin library?

@Mil4n0r
Copy link
Author

Mil4n0r commented Jun 6, 2024

Am I understanding correctly that you are using a fork of Toolpad and are trying to add components in the builtin library?

That is correct.

@Janpot
Copy link
Member

Janpot commented Jun 6, 2024

If you want you can open a PR with some minimal changes that demonstrate the problem. But I have to admit, this is not immediately a use case we're investing in. I might take a quick look, but you may have to do some debugging on this yourself.

@zannager zannager added the scope: toolpad-studio Abbreviated to "studio" label Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: toolpad-studio Abbreviated to "studio" status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants