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-knobs Select | Option values as Arrays #7600

Closed
nickofthyme opened this issue Jul 29, 2019 · 6 comments
Closed

addon-knobs Select | Option values as Arrays #7600

nickofthyme opened this issue Jul 29, 2019 · 6 comments

Comments

@nickofthyme
Copy link

Describe the bug
As of v5.1.9 I could use arrays or any custom type as an option value with the select knob. This functionality is now not allowed as of v5.2.0-beta.*.

To Reproduce
Steps to reproduce the behavior:

  1. Create the following select knob
const mySweetSelect = select(
  'mySelect',
  {
    ones: [1],
    twos: [2, 2],
    threes: [3, 3, 3],
  },
  [1],
);
  1. Notice with v5.2.0-beta.19 there is a type error for the option values as the select option value can only be one of...
    export type SelectTypeKnobValue = string | number | null | undefined;

It looks like since v5.1.9 you upgrade to typescript ( yay! 🎉) but this value restriction causes a breaking change. I wasn't sure to put this as a feature or bug but since it broke my current usage I decided to label it as a bug. Also considering it is allowable to have arrays as values per the latest docs.

Expected behavior
Allow a generic type as an option value....

type MySpecialType = number[];
const mySweetSelect = select<MySpecialType>(
  'mySelect',
  {
    ones: [1],
    twos: [2, 2],
    threes: [3, 3, 3],
  },
  [1],
);

System:

System:
OS: macOS 10.14.5
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Binaries:
Node: 10.15.2 - ~/.nvm/versions/node/v10.15.2/bin/node
Yarn: 1.16.0 - /usr/local/bin/yarn
npm: 6.9.0
Browsers:
Chrome: 75.0.3770.142
Safari: 12.1.1

Additional context
Add any other context about the problem here.

@shilman
Copy link
Member

shilman commented Jul 30, 2019

@emilio-martinez assigned you -- hope that's ok! 🙇

@emilio-martinez
Copy link
Contributor

@shilman sure thing! I'm on it :)

@stale stale bot added the inactive label Aug 21, 2019
@nickofthyme
Copy link
Author

ping

@stale stale bot removed the inactive label Aug 21, 2019
@storybookjs storybookjs deleted a comment from stale bot Aug 22, 2019
@shilman shilman added this to the 5.2.0 milestone Aug 22, 2019
@shilman
Copy link
Member

shilman commented Aug 27, 2019

@nickofthyme Did this not fix the issue? #7411

@nickofthyme
Copy link
Author

nickofthyme commented Aug 27, 2019

@shilman No that PR predates this issue. The issue I mentioned in that PR was regarding the Array knob.

This issue is regarding the use of an Array as a value in the Select knob.

In the next branch the select knob types still don't allow Arrays 👇 when the docs say otherwise.

export type SelectTypeKnobValue = string | number | null | undefined;

@shilman
Copy link
Member

shilman commented Sep 8, 2019

Olé!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.0-rc.9 containing PR #8027 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 Sep 8, 2019
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

3 participants