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

Stories in Docs view are sorted alphabetically #227

Closed
IanVS opened this issue Feb 3, 2022 · 12 comments
Closed

Stories in Docs view are sorted alphabetically #227

IanVS opened this issue Feb 3, 2022 · 12 comments
Labels
upstream This is an issue with another package

Comments

@IanVS
Copy link
Member

IanVS commented Feb 3, 2022

Stories are shown in the sidebar in the correct order, but they are ordered in the docs view alphabetically.

I've confirmed this is the case when using the latest storybook-builder-vite (0.1.15) and storybook 6.4.18.

@joshwooding
Copy link
Collaborator

This is going to be a long description 😆

This is because the docs page show the stories in export order which is always alphabetical. It was mentioned in this comment that the DocsPage Primary was being replaced.

This is because Primary.tsx calls componentStories() defined here: https://github.com/storybookjs/storybook/blob/64c31900964aa15420e6ec4e1d12f0b88961a457/lib/preview-web/src/PreviewWeb.tsx#L502 which is passed the csfFile from a couple lines above which is fetched using loadCSFFileByStoryId() which calls the importFn and passes the result to processCSFFileWithCache() which seems to intentionally not respect __namedExportsOrder judging by this test: https://github.com/storybookjs/storybook/blob/64c31900964aa15420e6ec4e1d12f0b88961a457/lib/store/src/csf/processCSFFile.test.ts#L51-L71.

Now that explanation is out of the way @shilman and @tmeasday (since you both were on the PR 🙂) do you have any thoughts on what we should do here?

@tmeasday
Copy link
Member

tmeasday commented Feb 6, 2022

OK, looks like this comment was a mistake @shilman: storybookjs/storybook#16626 (review)

I think maybe we should revert that part of the change, the sorting of exports in processCSFFile() is not useless after all!

@IanVS
Copy link
Member Author

IanVS commented Feb 28, 2022

@tmeasday @shilman should we open an issue in the storybook repo? Or is this being worked on already? Or would you like a PR that reverts that part of the change, as mentioned above?

@Joeycz
Copy link

Joeycz commented Mar 1, 2022

I got the same problem

@tmeasday
Copy link
Member

tmeasday commented Mar 1, 2022

I think that'd be great (the PR) but maybe @shilman can confirm, just in case?

@sebastienbarre
Copy link

sebastienbarre commented Mar 31, 2022

Thanks a lot guys for looking into this. Just switched from Webpack to this builder, and this took me by surprise rather immediately. Might I suggest to add it to the "Known Issues" in the README?

@IanVS
Copy link
Member Author

IanVS commented Mar 31, 2022

@sebastienbarre it looks like @shilman is taking a look at how to fix this (storybookjs/storybook#17793 (comment)), let's see if we can't take care of it before adding it to that list of issues.

@tmeasday
Copy link
Member

tmeasday commented Apr 1, 2022

@joshwooding sorry for not making the connection here until now, but I think we fixed the problem you describe with componentStories() not using the story index order in this PR (on the 9th of March), which was released in alpha.47.

Are you sure this issue is still active? It sounds like @sebastienbarre is saying it is, but maybe they aren't on the latest alpha?

@sebastienbarre
Copy link

sebastienbarre commented Apr 1, 2022

@tmeasday yes, sorry, I'm not on the alpha, I'm using v6.4.19. Will this land in the 6.x? Or is it a 7.x only? Thank you.

@IanVS
Copy link
Member Author

IanVS commented Apr 1, 2022

Oh awesome, I just checked our examples, which are on 6.5.0-alpha.49, and the story order is working correctly now. @sebastienbarre, this will land in 6.5.0 stable.

Closing this issue as fixed by storybookjs/storybook#17669. Thanks @tmeasday!

@IanVS IanVS closed this as completed Apr 1, 2022
@tmeasday
Copy link
Member

tmeasday commented Apr 1, 2022

Thanks all! No need to apologies @sebastienbarre just trying to clear up my own confusion :)

@joshwooding
Copy link
Collaborator

@joshwooding sorry for not making the connection here until now, but I think we fixed the problem you describe with componentStories() not using the story index order in this PR (on the 9th of March), which was released in alpha.47.

Are you sure this issue is still active? It sounds like @sebastienbarre is saying it is, but maybe they aren't on the latest alpha?

Ah awesome 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream This is an issue with another package
Projects
None yet
Development

No branches or pull requests

5 participants