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

Storybook 6.0 args don't maintain array order. #11605

Closed
lifeiscontent opened this issue Jul 18, 2020 · 5 comments
Closed

Storybook 6.0 args don't maintain array order. #11605

lifeiscontent opened this issue Jul 18, 2020 · 5 comments

Comments

@lifeiscontent
Copy link
Member

lifeiscontent commented Jul 18, 2020

Describe the bug
When using both typescript types and argTypes, the order of args are not maintained.

To Reproduce
Steps to reproduce the behavior:

  1. Create a component that has a prop with multiple options
  2. Add story with args
  3. See arg order is not maintained

Expected behavior
Args are ordered

Screenshots
Screen Shot 2020-07-18 at 3 41 17 PM

Code snippets
using this as props

interface Props {
  src: string;
  alt: string;
  size: 'smallest' | 'small' | 'medium' | 'large' | 'largest';
}
export function Example(
  args: React.ComponentPropsWithoutRef<typeof UIAvatar>
): JSX.Element {
  return <UIAvatar {...args} />;
}

Example.args = {
  src: 'avatar.jpg',
  alt: 'Avatar',
  size: 'medium',
};

System:
Please paste the results of npx -p @storybook/cli@next sb info here.

Environment Info:

System:
OS: macOS 10.15.6
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
Node: 12.8.1 - ~/n/bin/node
Yarn: 1.22.4 - ~/.yarn/bin/yarn
npm: 6.14.5 - ~/n/bin/npm
Browsers:
Firefox: 72.0.2
Safari: 13.1.2

Additional context
I don't know if this is possible, but I love you

@shilman
Copy link
Member

shilman commented Jul 18, 2020

@hipstersmoothie is this something you can look into? I think it's happening in react-docgen-typescript. Even worse it's nondeterministic, so our snapshot tests become flakey. Any help you can provide would be much appreciated!

@lifeiscontent
Copy link
Member Author

@shilman I looked into it more on the TypeScript side, looks like it might be planned to fix this behavior upstream, but currently no fix.

microsoft/TypeScript#17944

@hipstersmoothie
Copy link
Contributor

I could add an option to one of the underlying libraries to sort the props. I'm not sure this will ever get "fixed" in typescript

@shilman shilman modified the milestones: 6.0 args, 6.1 args Jul 30, 2020
@stale stale bot added the inactive label Aug 30, 2020
@stale stale bot closed this as completed Oct 4, 2020
@shilman shilman added the todo label Oct 4, 2020
@storybookjs storybookjs deleted a comment from stale bot Oct 4, 2020
@storybookjs storybookjs deleted a comment from stale bot Oct 4, 2020
@shilman shilman reopened this Oct 4, 2020
@stale stale bot removed the inactive label Oct 4, 2020
@shilman shilman modified the milestones: 6.1 args, 6.2 args Oct 13, 2020
@hipstersmoothie
Copy link
Contributor

Yeah I don't think this is fixable from anyone but the typescript team. So this could probs be closed in the meantime @shilman

@shilman
Copy link
Member

shilman commented Apr 13, 2021

We added user-configurable sorting here:

#13125

@shilman shilman closed this as completed Apr 13, 2021
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