question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addon-controls - Disabling controls for a story does not hide them on argsTable

See original GitHub issue

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 argstable-with-controls Control panel controls-disabled

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

To Reproduce Steps to reproduce the behaviour:

  1. 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" />
  1. Serve Storybook.
  2. Navigate to MyGreatComponent
  3. Click on the Canvas tab.
  4. See that the Controls tab is no visible.
  5. Click on the Docs tab.
  6. 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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:9

github_iconTop GitHub Comments

11reactions
joelstranskycommented, Aug 9, 2022

@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.

9reactions
eltranseunteurbanocommented, Sep 2, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

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="">...
Read more >
Controls - Storybook - JS.ORG
To use the Controls addon, you need to write your stories using args. Storybook will automatically generate UI controls based on your args...
Read more >
reactjs - @storybook/addon-controls: howto not auto-generate ...
disable within argTypes for a given arg. Suppose you have a story with foo and bar properties (auto-generated or otherwise) and you want...
Read more >
storybook/addon-controls - npm
How can I disable controls for certain fields on a particular story? The argTypes annotation can be used to hide controls for a...
Read more >
Next-level component showcasing with Storybook controls
args = { color: "#516dd0", };. Although it's not part of Storybook controls, I would like to say a few words about the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found