Skip to content
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

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

Open
novellac opened this issue Sep 1, 2020 · 16 comments

Comments

@novellac
Copy link
Contributor

novellac commented Sep 1, 2020

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
@VladimirCores
Copy link

How to completely hide control for prop from Controls pane?

@cbojaca
Copy link

cbojaca commented Oct 22, 2020

How can we hide a property from the controls page?

@shilman
Copy link
Member

shilman commented Oct 22, 2020

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

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

cc @jonniebigodes

@mahimachhalani
Copy link

How to disable controls for a story in MDX?

@shilman
Copy link
Member

shilman commented Oct 24, 2020

For a component:

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

For a story:

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

@FilipMessa
Copy link

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?

@shilman
Copy link
Member

shilman commented Nov 20, 2020

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

@shilman shilman modified the milestones: 6.1 args, 6.2 args Nov 24, 2020
@emilfjellstrom
Copy link

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.

@shilman
Copy link
Member

shilman commented Dec 13, 2020

@rayzoor12 it's an open issue #12693

@chalovega
Copy link

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.

@shilman
Copy link
Member

shilman commented May 5, 2021

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

@JokerDang
Copy link

JokerDang commented Jul 23, 2021

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

@shilman
Copy link
Member

shilman commented Jul 23, 2021

@JokerDang unfortunately you can't

@JokerDang
Copy link

@shilman , I saw you created PR for similar this feature.
#13890

so it work now ?

@shilman
Copy link
Member

shilman commented Jul 25, 2021

No the PR was closed without merging

@rdebeasi
Copy link

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

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

@shilman shilman removed the P1 label Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants