storybook: 5.0.0-rc.9: Option sortStoriesByKind is not working

addParameters(
  {
    options: {
      theme: create({
        base: "light",
        brandTitle: "Test",
      }),
      sortStoriesByKind: true,
    },
  },
);

sortStoriesByKind is not working, true/false it’s the same.

5.0.0-rc.9

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 27
  • Comments: 35 (20 by maintainers)

Most upvoted comments

It does not seem like sortStoriesByKind is implemented at all in v5+ based on this search which shows the only places it’s referenced are in documentation about the feature but it’s not actually used anywhere.

My hope is that there’s some kind of API in the works that’ll allow us to provide our own sorting function! ❤️

In v4, we had hacked something into .storybook/config.js which accessed window.__STORYBOOK_CLIENT_API__._storyStore.getStoryKinds() and sorted window.__STORYBOOK_CLIENT_API__._storyStore._data based on that, but that’s obviously now broken w/ our update to v5.

Would be soooo sweet to be able to supply sortStories func in config that returns -1|0|1

Still not working in v5.0.5

Also an issue with the other options in the ui object: enableShortcuts and sidebarAnimations

We released #6472 in 5.2.0-alpha and I’ll update MIGRATION.md accordingly

Hello,

I’m sorry if it’s a silly question 😅 But I’m not used to sortStoriesByKind and I don’t find any documentation on storySort.

Where do these id come from? I would like to sort the stories manually. How can I do that?

Thank you for your help 😊

It does not seem like sortStoriesByKind is implemented at all in v5+ based on this search which shows the only places it’s referenced are in documentation about the feature but it’s not actually used anywhere.

Pure WTF. @leoyli @shilman @ndelangen Please remove from documentation, or show a giant warning next to each option which is “todo”

This is still happening in 5.0.1 for us.

@mlegait You could add a story parameter and sort by that?

storiesOf(...).add('foo', () => <Foo />, { order: 1 });

In the new component story format:

export const foo = () => <Foo/>;
foo.story = {
  parameters: { order: 1 }
};

Pretty sure it will show up in a.parameters.order, but I didn’t verify.

Thank you @shilman 🎉 Tried it in 5.2.0-alpha.35 and it worked.

Just in case: sortStoriesByKind changed to storySort and expects a function now.

addParameters({
  options: {
    storySort: (a, b) => a[1].id.localeCompare(b[1].id),
  },
});

We’re in the final phase of the 5.1 release. I just had a short discussion with @shilman & @tmeasday about this, and although https://github.com/storybooks/storybook/pull/6472 is very promising, we feel it’s a bit too late into the process to merge this into 5.1.

This will be get fixed in v5.2.

Reason being: The visual sorting & sorting of the keyboard shortcuts are kinda independent and haven’t been thoroughly tested.