storybook icon indicating copy to clipboard operation
storybook copied to clipboard

addon-controls - Disabling controls for a component does not disable them on docsPage

Open novellac opened this issue 4 years ago • 16 comments

Describe the bug When I set the parameter for controls to disabled, the Controls tab disappears, but controls are still present on the docsPage.

To Reproduce Steps to reproduce the behavior:

  1. In a *.stories.js file (maybe MDX too, but I have only verified this on *.stories.js), set the export default as such:
export default {
  title: 'Components/MyNiceComponent',
  component: MyNiceComponent,
  parameters: {
    controls: {
      disabled: true,
    }
  }
}
  1. Serve Storybook.
  2. Navigate to MyGreatComponent
  3. See that the Controls tab is no longer visible.
  4. Click on the Docs tab.
  5. See that the controls are still visible, and still function.

Expected behavior When I disable controls for a component, I expect both the controls tab to disappear AND the controls column on the docsPage to disappear, as well.

System:

  System:
    OS: macOS 10.15.6
    CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
  Binaries:
    Node: 12.18.3 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.6 - /usr/local/bin/npm
  Browsers:
    Chrome: 85.0.4183.83
    Firefox: 80.0
    Safari: 13.1.2

novellac avatar Sep 01 '20 17:09 novellac

How to completely hide control for prop from Controls pane?

VladimirCores avatar Oct 19 '20 10:10 VladimirCores

How can we hide a property from the controls page?

cbojaca avatar Oct 22 '20 00:10 cbojaca

disabling a single row foo from showing up in the table:

export default {
  title: ...,
  component: ...,
  argTypes: {
    foo: { table: { disable: true } }
  },
}

cc @jonniebigodes

shilman avatar Oct 22 '20 01:10 shilman

How to disable controls for a story in MDX?

mahimachhalani avatar Oct 23 '20 20:10 mahimachhalani

For a component:

<Meta
  title=...
  component={...}
  argTypes={{
    foo: { table: { disable: true } }
  }}
/>

For a story:

<Story
  name=...
  argTypes={{
    foo: { table: { disable: true } }
  }}
>
  ...
</Story>

shilman avatar Oct 24 '20 14:10 shilman

Is it possible to do the opposite? I mean, I set the controls to hide by default and then enable what I want to see?

FilipMessa avatar Nov 20 '20 17:11 FilipMessa

In MDX the ArgsTable block has an include prop that does what you want. But not for the other use case unfortunately @FilipMessa

shilman avatar Nov 20 '20 17:11 shilman

An addition to this, is there a way to disable the controls, but still have them shown? I have a boolean I always want to be true in a curtain state and I want to show its supposed to be true when displaying this component.

emilfjellstrom avatar Dec 11 '20 13:12 emilfjellstrom

@rayzoor12 it's an open issue #12693

shilman avatar Dec 13 '20 09:12 shilman

is there a way to disable all controls for a story? (without having to disable one by one with table: {disable:true}). I want to have one interactive story (with controls) and the other stories just as read only use cases.

chalovega avatar May 04 '21 18:05 chalovega

@chalovega-cs I think you can filter all of them like this: https://storybook.js.org/docs/react/essentials/controls#filtering-controls

shilman avatar May 05 '21 11:05 shilman

Hi @shilman, How can I conditionally disable a control in Storybook based on the value of another argument?

JokerDang avatar Jul 23 '21 09:07 JokerDang

@JokerDang unfortunately you can't

shilman avatar Jul 23 '21 14:07 shilman

@shilman , I saw you created PR for similar this feature. https://github.com/storybookjs/storybook/pull/13890

so it work now ?

JokerDang avatar Jul 25 '21 03:07 JokerDang

No the PR was closed without merging

shilman avatar Jul 25 '21 07:07 shilman

Possible workaround: in preview.js, filter out all the controls:

export const parameters = {
  controls: {
    exclude: /^.*?/
  },
};

rdebeasi avatar Apr 26 '22 19:04 rdebeasi