-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Tree of stories loses order on HMR #6439
Comments
Related: #5827 |
More information on this This is important because the rendering of the stories is done using https://github.com/storybooks/storybook/blob/next/lib/ui/src/components/sidebar/treeview/utils.js#L8 which loops over the object in the order in which keys were added. The most straight forward solution would probably be to copy the entire this._data removing and re-adding all the keys for each "addStory" via a sorting function from global options. The good news is it's not a real copy, so it shouldn't take that long. The bad news is that it would happen a lot during start up... It could also affect a large portion of the tree if some core file was edited and invalidated a whole bunch of stories. Otherwise, we could use a sort function during the tree rendering, I don't know what kind of performance hit we'd take with that. It'd be more predictable though as the sort would happen every time and we could potentially memo it. Thoughts? |
IMO the right solution is to support a sort function. Users want it, and then it ends any questions about what the order should be. |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
@tmeasday does this fall under your purview? |
@snowystinger sorry I did not comment on this sooner. As I mentioned here: #6472 (comment) I don't think sorting in the treeview is correct, and I think probably sorting on the manager side in Another small thing is that I noticed here that the sort order of roots is currently inconsistent across browsers due to a miswritten While we fix this issue it would make sense to reimplement I am not sure if it's going to fly with users to remove the current default (sort stories by import order), even if it does have this bug right now. I wonder if we can fix this issue another way (without sorting). One hacky solution would be:
@shilman I think we should keep this problem in mind when thinking about how to handle HMR for |
@snowystinger feel free to reach out on discord if you want to get into the details of this together. |
@tmeasday love the hack 💯 |
Actually I thought a bit more about this in discussions with @shilman and I'm thinking we could after all sort the stories in the preview before sending them over the wire. Basically the format that goes over the wire is a large array of stories (although it is actually an object). We could in fact sort the stories in the If the stories enter the manager in the correct order then no special sorting would be required to make the treeview look right. I think this is the way to go because it makes other code that is interested in the story order able to rely on |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hi there. This bug seems pretty serious, it ruins the whole nice experience of developing in storybook. Are you waiting for PR? Is there a solution you agreed on? |
Hi @beshanoe - yes, you are correct, that PR contains a fix, and will be merged into our main release branch sometime after 5.1 is released (very soon). I'm not quite sure when the fix will make it out. |
Whoopee!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.0-alpha.31 containing PR #6472 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
Describe the bug
Tree of stories loses order on hmr
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Tree should stay in order
Screenshots
Code snippets
If applicable, add code samples to help explain your problem.
System:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: