-
-
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
addon-backgrounds: global context not initially updated with color #15632
Comments
After some digging, it looks like the so-called storybook/lib/client-api/src/story_store.ts Lines 216 to 228 in 209b6c4
@ghengeveld could you shed some light on this per you changes in #15056? Basically, adding // preview.js
export const parameters = {
+ globals: {
+ backgrounds: {}
+ },
backgrounds: {
// ... Still doesn't solve the default case where no global param is present. @ghengeveld seeing as you know the globals code fairly well, do you have any ideas why the globals from an addon would not be populated until the |
this looks like a bug with also cc @stevensacks since you're using the same pattern in your i18n work AFAICT what's going on here is that the globals code in core assumes that the globals are declared statically, either by the end user or by addons. what that would look like: // .storybook/preview.js
export const globalTypes = { ... };
export const globals = { ... }; If you don't declare a
Given this pattern, we could fix the problem:
I think the first fix is closer to the design intent of globals. WDYT? |
I think I agree @shilman |
@shilman based on the inability to statically define the initial background color are you okay with the changes in #15640? |
@nickofthyme Maybe I don't understand the issue very well, but in your demo, you tried to get the value of |
@bytrangle the issue is that it does not capture the initial default value in The whole
Is this not true? If it is I'd think the demo would work as is. All in all how do you make the demo work so that it passes the initial default value to the decorators? In my custom background addon I have to call |
Is this still an issue with 7.0 beta? |
+1 I'm still seeing this issue with Svelte stories |
+1 Still experiencing this issue. Would love to get defaults working on a per Story basis, this would save our dev team lot of boilerplate for setting up background color styles for every Story. |
Describe the bug
When using
@storybook/addons-backgrounds
in a react project with a customDecorator
, the initial/default background value is not passed to thecontext.globals
.I have a project performing text contrast logic where I need the initial value to pass to javascript.
To Reproduce
console.log
of thecontext.globals
shows and empty object.context.globals
now includes the selected value.System
Additional context
Could be related to #14846
The text was updated successfully, but these errors were encountered: