storybook: addon-controls - Disabling controls for a story does not hide them on argsTable
Describe the bug
When I set the controls parameter to { disabled: true } for a story, the “Control” column into <argsTable story=""> doesn’t disappear, even if I override argTypes on story with control: { type: null }.
Case 1: <Story parameters={{ controls: { disable: true } }}></Story>
argsTable
Control panel

Case 2: <Story argTypes={{ title: { control: { type: null } } }}></Story>
argsTable
Control panel

To Reproduce Steps to reproduce the behaviour:
- In a *.stories.mdx file:
import {
Meta,
Story,
Canvas,
ArgsTable,
} from '@storybook/addon-docs'
import html from './card.html'
<Meta
title="Components/Card"
parameters={{
viewMode: 'docs',
}}
args={{
title: '',
}}
argTypes={{
title: {
name: 'Titre',
description: 'Titre de l’article',
type: { name: 'string', required: true },
table: {
type: {
summary: 'string',
},
defaultValue: { summary: '' },
},
control: { type: 'text' },
}
}}
/>
export const PlaygroundTmpl = (args) => `
<div class="Card">
<h4 class="Card-title">${args.title}</h4>
</div>
`
# Card
<Canvas>
<Story
name="Card"
height="600px"
parameters={{
controls: { disable: true },
docs: { source: { code: html } },
viewMode: 'story',
}}
>
{PlaygroundTmpl.bind({})}
</Story>
</Canvas>
<ArgsTable story="Card" />
<Canvas>
<Story
name="Card 1"
height="600px"
parameters={{
controls: { disable: true },
docs: { source: { code: html } },
viewMode: 'story',
}}
argTypes={{
title: { control: { type: null } },
}}
>
{PlaygroundTmpl.bind({})}
</Story>
</Canvas>
<ArgsTable story="Card 1" />
- Serve Storybook.
- Navigate to MyGreatComponent
- Click on the Canvas tab.
- See that the Controls tab is no visible.
- Click on the Docs tab.
- See that the “Control” column and the reload button are still visible.
Expected behaviour
When I disable controls for a story (or all controls are null), I expect the “Control” column and the reload button into <argsTable>component to disappear and the Control panel to be empty.
System
System:
OS: Windows 10 10.0.19043
CPU: (8) x64 Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
Binaries:
Node: 14.17.0 - C:\nodejs\node.EXE
npm: 6.14.13 - C:\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.423.0), Chromium (92.0.902.62)
npmPackages:
@storybook/addon-essentials: ^6.3.4 => 6.3.6
@storybook/addon-links: ^6.3.4 => 6.3.6
@storybook/addons: ^6.3.6 => 6.3.6
@storybook/html: ^6.3.4 => 6.3.6
@storybook/preset-scss: ^1.0.3 => 1.0.3
@storybook/theming: ^6.3.4 => 6.3.6
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 7
- Comments: 15
@ops1ops Storybook docs are famously bad. They are more of a blog about storybook than a simple listing of api. I’m not sure why no one does this anymore.
Controls does not hidden on args table, for that exist another property.
If you want to hidde some property on table, you have to use table.
title: { table: { disable: true } }You can check the documentation here
Leaving the prop for documentation purposes only and disabling the ability to change the component can be done like so:
This is now mentioned here: https://storybook.js.org/docs/react/essentials/controls#disable-controls-for-specific-properties
any news? its kind of weird that disabling table (which corresponds to doc page) deletes control, and i cant override it by directly writing “control”, according to current api, ArgsTable component has exclude property, but i need to recreate docs markup for each story where i want to disable some properties from doc - it requires a lot of code easier would be to move this property to argTypes or fix current behavior with table disabling
P.S. What is wrong with docs? Why do i get know about “disable” property from issues on github? Currently https://storybook.js.org/docs/react/writing-docs/doc-block-argstable#argstable does not have info about disable property and about exclue/include
Can we disable controls for the whole story without going into the each and every prop? There are only 2️⃣ , but still…😃
@7studio As a workaround you could wrap the
<ArgsTable />with a<div>and give it an id and use some CSS to hide the column.In your stories.mdx file:
in a .storybook/storybook.css (override) file:
make sure to setup that storybook.css override in .storybook/preview.js:
@FilipePfluck and @manavm1990 Took me a while to figure this out, and it may not work for your needs, but I personally use the
propFilterfunction to filter out props defined innode_modulesvia mytypescriptconfig in main.js:Source(ish): https://storybook.js.org/docs/react/configure/typescript#extending-the-default-configuration
@manavm1990 @FilipePfluck you can overwrite
extractArgTypeswhich is the function used to infer all the arg types of a component.You can check how the default function is implemented here: https://github.com/storybookjs/storybook/blob/aecfa1791f982bef6a06b51d20df3e31dd82b5b4/code/renderers/react/src/docs/extractArgTypes.ts#L5
The function implementation is different between frameworks. The one above is for React. You can look for the others inside the repo.
You can set this in
preview.jsto change all stories, in the default export of a file to change all stories in that file or in a single story.I have the same question as @manavm1990. I am usiong pandacss to style my components, and they can receive hundreds of styling properties, I want to hide them in storybook. And ain’t no way Imma disable all of them manually.
I have another problem. For good measure I write this in global
argTypes:But if I do this,
styleprop is visible under every story. This does not always happen though. Also, it does not show in Docs tab, but only in Canvas tab. This is very weird.