-
-
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
Knobs disappear #2409
Comments
Got the same issue with storybook/[email protected] |
@powermikee I have the same issue, but only when my knobs are added through I also noticed, that they appear again for a split of second during resizing of the panel. |
I noticed exactly the same behavior shortly after I tried adding a light/dark theme knob globally in StorybookStyleDecorator.js
config.js
|
I was able to fix it by combining the two files into one and calling
This was inspired by an earlier version of Storybook's solution for global knobs: |
@powermikee @andest01 @jalooc @ralzinov is this still happening with the latest alpha. Some time ago I did a big refactor that fixed a bunch of weird issues, please let me know if this is happening |
@alterx Just gave it a shot with the latest alpha, still happening. Defining knobs in decorators would be a really powerful feature when working with themes, etc. Edit: I can't get it working with @andest01's workaround either. @andest01 - what version are you on? Edit (2): Actually, I can get this working without the workaround (on the latest stable version), as long as the |
The problem with defining "global" knobs, if I'm understanding this correctly is that this would have to be applied as yet another wrapper component that we need to keep around when switching stories. This is something that needs some thought, specially on angular and similar frameworks (not react o preact). I suspect this global behavior could be happening with all the apps and Knobs (not only Angular). Do you have a working repo in which we can replicate the issue? |
Happening to me as well, only when defining globally. Edit:Ok, so the solution I found was actually opposite of what @angusfretwell found, interestingly enough. What worked for me was adding the config.js index.stories.js
|
For me, I stumbled upon another fix for this issue. I still have withKnobs defined globally in my storybook config, but then in my I was trying to do this (as the docs advise you to do), which was not working: const valueWidth = number(labelWidth, defaultValueWidth, optionsWidth)
stories.add('Default Divider', () => (
<Divider
width={valueWidth}
/>
)) and it would disappear. When I switched it from the reference to using the function directly, it worked no problem: stories.add('Default Divider', () => (
<Divider
width={number(labelWidth, defaultValueWidth, optionsWidth)}
/>
)) Hope this helps someone. |
@camsloanftc trick did the trick. Any news on a more structured solution? |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
We use something like this in our project: const BasicComponent = (props = {}) => {
const defaultProps = {
// some props...
label: text('label', 'Default label'),
value: number('value', 0),
...props // Override defaults if needed,
};
return <Component {...defaultProps} />;
}
storiesOf('Component', module)
.add('Default', () => <BaseComponent />)
.add('With overridden defaults', () => <BaseComponent someProp={value} />); Basically, just avoid having file-scoped knobs. |
This solved it for me: https://stackoverflow.com/a/57067253/1048589 |
The text was updated successfully, but these errors were encountered: