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

Boolean default value not showing up in Addon-docs prop table #9394

Closed
vimtor opened this issue Jan 12, 2020 · 8 comments
Closed

Boolean default value not showing up in Addon-docs prop table #9394

vimtor opened this issue Jan 12, 2020 · 8 comments

Comments

@vimtor
Copy link

vimtor commented Jan 12, 2020

Describe the bug
When using addon:docs prop table for React tsx components the boolean default values don't show up in the table.

To Reproduce

  1. Follow this guide
  2. Add some boolean prop like this:
import React, { FC } from "react";

interface ButtonProps {
  /**
   * Simple click handler
   */
  onClick?: () => void;
  /**
   * Is primary?
   */
  primary: boolean;
}

/**
 * The world's most _basic_ button
 */
export const Button: FC<ButtonProps> = ({ children, onClick }) => (
  <button onClick={onClick} type="button">
    {children}
  </button>
);

Button.defaultProps = {
  primary: true
};
  1. Run yarn storybook and see the result.

72208407-20e97480-349a-11ea-9255-647840810252

Expected behavior
Default values showing up.

System:
System:
OS: Linux 5.0 Ubuntu 18.04.3 LTS (Bionic Beaver)
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Binaries:
Node: 10.18.0 - /usr/bin/node
Yarn: 1.21.1 - /usr/bin/yarn
npm: 6.13.4 - /usr/bin/npm
Browsers:
Chrome: 79.0.3945.88
Firefox: 71.0
npmPackages:
@storybook/cli: ^5.3.0 => 5.3.0

@mrmckeb
Copy link
Member

mrmckeb commented Jan 12, 2020

@shilman I've looked over this and it appears to be an issue with Docs itself.

The default here is 'false' or 'true'. When testing, all default values come through unless Boolean. My guess is that we need to stringify the values, at least when boolean.

@papeloto are you interested in having a go at this? If not, let me know and I can take a look and make the fix :)

@ZhihaoLau
Copy link

same here, boolean defaultProps disappear after upgrade to 5.3.x

@shilman
Copy link
Member

shilman commented Jan 20, 2020

Yee-haw!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.7 containing PR #9525 that references this issue. Upgrade today to try it out!

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Jan 20, 2020
@vimtor
Copy link
Author

vimtor commented Jan 20, 2020

Just upgraded to v5.3.7

image

Now false values don't show up 😂

Button.defaultProps = {
  variant: "primary",
  disabled: false,
  type: "button",
  inline: false,
  accessibilityLabel: "Button",
  uppercase: true,
  expand: false
};

@shilman
Copy link
Member

shilman commented Jan 21, 2020

Ooh-la-la!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-alpha.0 containing PR #9560 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Jan 21, 2020
@shilman shilman removed this from 5.3 bugs in Hotlist Jan 21, 2020
@shilman
Copy link
Member

shilman commented Jan 21, 2020

Jiminy cricket!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.8 containing PR #9560 that references this issue. Upgrade today to try it out!

@LeandrodeLimaC
Copy link

Using "@storybook/react": "^6.5.13" and ran into the same issue 😅

args: {
    defaultChecked: false,
    checked: false,
  },
  argTypes: {
    checked: {
      defaultValue: 'indeterminate',
      options: [false, true, 'indeterminate'],
      control: { type: 'inline-radio' },
    },
    defaultChecked: {
      defaultValue: false,
    },
  }

I had to display those as inline radio so at least it shows wich option is select by default
image

@Fritze1602
Copy link

Fritze1602 commented Nov 25, 2022

Can confirm, that the issue is still around in 6.5.13. But despite @LeandrodeLimaC workaround the default false booleans are NOT shown by "ShowCode" in the docs.

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

7 participants