Skip to content

Commit

Permalink
Core: Use stable package to ensure story sorting is stable (#8795)
Browse files Browse the repository at this point in the history
Core: Use `stable` package to ensure story sorting is stable
  • Loading branch information
shilman authored Nov 12, 2019
2 parents c05036a + ee614e8 commit 6455fc9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/client-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"lodash": "^4.17.15",
"memoizerific": "^1.11.3",
"qs": "^6.6.0",
"stable": "^0.1.8",
"ts-dedent": "^1.1.0",
"util-deprecate": "^1.0.2"
},
Expand Down
3 changes: 2 additions & 1 deletion lib/client-api/src/story_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import EventEmitter from 'eventemitter3';
import memoize from 'memoizerific';
import debounce from 'lodash/debounce';
import dedent from 'ts-dedent';
import stable from 'stable';

import { Channel } from '@storybook/channels';
import Events from '@storybook/core-events';
Expand Down Expand Up @@ -129,7 +130,7 @@ export default class StoryStore extends EventEmitter {
);
if (index && this._data[index].parameters.options.storySort) {
const sortFn = this._data[index].parameters.options.storySort;
stories.sort(sortFn);
stable.inplace(stories, sortFn);
}
}
// removes function values from all stories so they are safe to transport over the channel
Expand Down

0 comments on commit 6455fc9

Please sign in to comment.