storybook: [Bug]: v7 -> v8 controls tab is missing a lot of information
Describe the bug
v7: (7.6.17)
v8: (8.0.0)
To Reproduce
Removed a LOT of bloat, but this should do:
import type {Meta, StoryObj} from '@storybook/react';
import {MarkdownEditor} from './MarkdownEditor';
const meta: Meta<typeof MarkdownEditor> = {
component: MarkdownEditor
};
export default meta;
type Story = StoryObj<typeof MarkdownEditor>;
export const Default: Story = {};
export const Collapsed: Story = {
args: {
initialState: 'collapsed'
}
};
export const Expanded: Story = {
args: {
initialState: 'expanded'
}
};
import React, {useRef, useState} from 'react';
import type {ReactElement, FunctionComponent, FormEventHandler} from 'react';
type MarkdownEditorProps = {
/**
* Custom description
*/
initialState?: 'collapsed' | 'expanded';
onInput?: FormEventHandler<HTMLDivElement>;
value?: string;
initialValue?: string;
};
type MarkdownEditorComponent = FunctionComponent<MarkdownEditorProps>;
type MarkdownEditorElement = ReactElement<MarkdownEditorProps>;
export const MarkdownEditor: MarkdownEditorComponent = ({
initialState = 'collapsed'
}): MarkdownEditorElement => null;
System
Storybook Environment Info:
System:
OS: Windows 10 10.0.19045
CPU: (8) x64 Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz
Binaries:
Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
Yarn: 4.1.1 - C:\Program Files\nodejs\yarn.CMD <----- active
npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Chromium (122.0.2365.80)
npmPackages:
@storybook/addon-a11y: ^7.6.17 => 7.6.17
@storybook/addon-console: ^3.0.0 => 3.0.0
@storybook/addon-essentials: ^7.6.17 => 7.6.17
@storybook/addon-interactions: ^7.6.17 => 7.6.17
@storybook/addon-knobs: ^7.0.2 => 7.0.2
@storybook/addon-links: ^7.6.17 => 7.6.17
@storybook/addon-toolbars: ^7.6.17 => 7.6.17
@storybook/blocks: ^7.6.17 => 7.6.17
@storybook/jest: ^0.2.3 => 0.2.3
@storybook/react: ^7.6.17 => 7.6.17
@storybook/react-vite: ^7.6.17 => 7.6.17
@storybook/test: ^7.6.17 => 7.6.17
@storybook/test-runner: ^0.17.0 => 0.17.0
@storybook/testing-library: ^0.2.2 => 0.2.2
@storybook/testing-react: ^2.0.1 => 2.0.1
msw-storybook-addon: 2.0.0-beta.1 => 2.0.0-beta.1
storybook: ^7.6.17 => 7.6.17
Additional context
Switching between the two versions (and restarting storybook dev) is enough to trigger this issue - config and code remains untouched
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 16 (3 by maintainers)
Commits related to this issue
- chore: use react-docgen-typescript instead of react-docgen https://storybook.js.org/blog/storybook-8/#improved-react-and-vue-control-autogeneration https://storybook.js.org/docs/api/main-config-types... — committed to Qovery/console by ctjhoa 3 years ago
- chore: use react-docgen-typescript instead of react-docgen https://storybook.js.org/blog/storybook-8/#improved-react-and-vue-control-autogeneration https://storybook.js.org/docs/api/main-config-types... — committed to Qovery/console by ctjhoa 3 years ago
- chore: fix storybook config / migrate to storybook 8 (#1348) * chore: move to storybook 8 * chore: replace storybook-tailwind-dark-mode with @storybook/addon-themes * chore: use react-docgen-ty... — committed to Qovery/console by ctjhoa 3 years ago
- Changing the default settings to use the typescript docgen results in much fewer changes See https://github.com/storybookjs/storybook/issues/26496 — committed to CMSgov/design-system by pwolfert 3 years ago
- [NO-TICKET] Upgrade React types to fix Storybook 8 branch (#3080) * WIP: Try upgrading the react types and working through errors Here's the summary of errors we're starting with: ``` Found 10... — committed to CMSgov/design-system by pwolfert 2 years ago
- [WNMGDS-2698] Upgrade Storybook (#3003) * bump storybook to latest packages * update storybook files using SB migration scripts * use correct markdown comment structure * replace ArgsTable w... — committed to CMSgov/design-system by zarahzachz 2 years ago
Can we get this issue re-opened? As this issue still persists.
I am using forwardRef components, and the only way to get
react-docgento display the descriptions is to do what is mentioned in the above comment (declare the prop types in two places). We shouldn’t have to do this though, as the type exists and you should be able to access it via an abstract syntax tree or similar. I’m guessing this is how it was working in v7 withreact-docgen-typescript?For additional context, I expect:
to show the correct prop descriptions.
There is some stuff that I found out recently, that might help somebody.
When using
forwardReformemoor HOC, it must be used like this:Even if the second
ButtonPropsis not needed, it has to beprops: ButtonProps, otherwise no controls show up.The declaration of props have to be in a plain interface with no magic:
This works as expected. But in one big project I use polymorphic components and the props are not declared using a simple interface, they are defined like this:
This was working with v7 but does not work with Storybook 8 anymore.
Storybook config in main.ts:
For one project I was using
docs: falsein the config to disable the “Docs” tab completely (because there’s an extra documentation website for this).In v7 this was fine, but if you use the same in Storybook 8 no controls show up. Also it’s not needed anymore, so just remove it or set
docs: true(which is the default).Update: I just found out that I did not configure reactDocgen correctly in the main.ts. It must be
With this, I can confirm that the documentation is generated properly.
I noticed that with
react-docgen-typescriptgenerates controls only once, when you start storybook. That means that if you change your type annotations in your component props - it will not update controls. You will have to manually restart storybook. Maybe that will help.