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-docs ArgsTable API requires 'control' prop to be present to have an overriding effect

See original GitHub issue

Describe the bug In order to work around a separate vue-docgen-api issue with TS types in Vue not displaying verbose enough, I am trying to override the type of my props in the ArgsTable by following these instructions: https://storybook.js.org/docs/react/api/argtypes#manual-specification and https://storybook.js.org/docs/react/writing-docs/doc-blocks#customizing

However, the argTypes objects that I have added to the MDX <Story> do not override the Type in the props table unless I also add a control: { type: null } prop to each prop object. It works correctly, updating/fixing/overriding the type, when I include that node, with the additional side-effect of adding an unwanted Controls column to my ArgsTable.

In an ArgsTable where I attempt to make more than one type correction, simply including the control: { type: null } on one prop is enough to make all the other props adopt their corrected types.

While type is my use case, I also noted that the description field follows the same behavior – it too requires the control node to be present to take an overriding effect.

Please see the Code Snippets area below to see two examples.

To Reproduce Steps to reproduce the behavior:

  1. Adjust the ArgTypes of a story/component by setting table: { type: { summary: 'NewType' } }
  2. Observe that the type in the ArgTable is not changed to “NewType”

Expected behavior The ArgsTable should use the overrides described in the argTypes object without any other required properties on the argsTypes node.

Code snippets The following example does not change the Type field in the ArgsTable

<Story name="ImageSlider"
    argTypes={{
      images: {
        table: {
          type: {
            summary: 'ImageInterface[]'
          }
        }
      },
...
</Story>

The following example does change the Type field in the ArgsTable, and adds an unwanted “Controls” column:

<Story name="ImageSlider"
    argTypes={{
      images: {
        table: {
          type: {
            summary: 'ImageInterface[]'
          }
        },
        control: {
          type: null,
        },
      },
...
</Story>

System:

Environment Info:

  System:
    OS: macOS 10.15.6
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  Binaries:
    Node: 14.4.0 - /usr/local/bin/node
    npm: 6.14.4 - /usr/local/bin/npm
  Browsers:
    Chrome: 85.0.4183.83
    Firefox: 75.0
    Safari: 13.1.2
  npmPackages:
    @storybook/addon-actions: >=6.0.21 => 6.0.21 
    @storybook/addon-docs: >=6.0.21 => 6.0.21 
    @storybook/addon-knobs: >=6.0.21 => 6.0.21 
    @storybook/addon-links: >=6.0.21 => 6.0.21 
    @storybook/addon-notes: ^5.3.21 => 5.3.21 
    @storybook/vue: >=6.0.21 => 6.0.21 

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
shilmancommented, Mar 11, 2021

@sneyed Hmm that’s a bug. Will dig in

1reaction
stale[bot]commented, Oct 4, 2020

Hi everyone! Seems like there hasn’t been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don’t have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

addon-docs ArgsTable API requires 'control' prop to be present to ...
It works correctly, updating/fixing/overriding the type, when I include that node, with the additional side-effect of adding an unwanted Controls column to my ......
Read more >
ArgsTable - Storybook - JS.ORG
Storybook is a frontend workshop for building UI components and pages in isolation. Thousands of teams use it for UI development, testing, and...
Read more >
@types/storybook__addon-knobs | Yarn - Package Manager
Fast, reliable, and secure dependency management. ... Addon-docs: Fix ArgsTable sorting when using of={Component} (#14669); Server: Fix string escaping in ...
Read more >
https://raw.githubusercontent.com/storybooks/story...
Bug Fixes - Addon-docs: Fix un-prefixed path links ([#14334](https://github.com/storybookjs/storybook/pull/14334)) - UI: Add aria-labels to buttons without ...
Read more >
Storybook: addons/docs/docs/props-tables.md - Fossies
MyComponent.stories.mdx import { ArgsTable } from '@storybook/addon-docs'; ... These controls are implemented appear automatically in the props table when ...
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