-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[Bug]: Error when switching themes (addon-themes) #24351
Comments
I was able to solve this by adding this block to my const preview: Preview = {
globalTypes: {
theme: { type: 'string' },
},
... your config |
@tjwiebell It works! Thanks! |
@tjwiebell thanks for the workaround, and looking forward to the patch! Be sure to check the contribution guide and hop onto the Storybook Discord if you need any help getting started. cc @integrayshaun as maintainer of the addon |
@cristian-atehortua @tjwiebell how odd! The global is declared in the Are you both using 7.4.5? |
Hi @integrayshaun, yes. I'm using 7.4.5 |
@cristian-atehortua @tjwiebell Can one of you give me a reproduction of this issue? I wasn't able to replicate it in a 7.4.5 sandbox |
Confirming I'm also on 7.4.5. Only commonality I see is we're both using monorepo setups, but I'll work on a repro in StackBlitz. |
Reproduction instance can be found here; logs the warning message in the console when trying to switch themes. https://stackblitz.com/edit/github-weunpu?file=packages%2Fstorybook%2F.storybook%2Fpreview.ts |
Thanks for the reproduction @tjwiebell. I was able to fix the issue (both in StackBlitz and locally) by removing the usage of I'm not sure why this fixes it (I would think both methods should work) and I'm not sure why |
According to the comment added to this function when Storybook is initialized: /**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/ According to that, there are cases in which these function calls can not be removed. So removing them it's a workaround, too. We still need to find and solve the root cause. |
Great @JReinhold. Thanks! |
Describe the bug
When using
withThemeByClassName
from@storybook/addon-themes
and trying to switch from the default theme to another it gets a message on the console: "Attempted to set a global (theme) that is not defined in initial globals or globalTypes".When clicking in the theme selector and clicking on "Dark theme" to switch themes, the theme is not changed and the mentioned message appears in the console.
To Reproduce
No response
System
Additional context
No response
The text was updated successfully, but these errors were encountered: