Skip to content

Commit

Permalink
Merge pull request storybookjs#15527 from dexster/Composition_order
Browse files Browse the repository at this point in the history
Composition: Fix refs ordering
  • Loading branch information
shilman authored Jul 9, 2021
2 parents 4ddb363 + 0d54d34 commit a24616a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
15 changes: 15 additions & 0 deletions examples/angular-cli/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,19 @@ module.exports = {
angularOptions: {
enableIvy: true,
},
// These are just here to test composition. They could be added to any storybook example project
refs: {
first: {
title: 'Composition test one',
url: 'https://storybookjs.netlify.app/cra-ts-essentials',
},
second: {
title: 'Composition test two',
url: 'https://storybookjs.netlify.app/cra-ts-essentials',
},
third: {
title: 'Composition test three',
url: 'https://storybookjs.netlify.app/cra-ts-essentials',
},
},
};
9 changes: 8 additions & 1 deletion lib/api/src/modules/refs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,15 @@ export const init: ModuleFn = ({ store, provider, singleStory }, { runCheck = tr

updated[id] = { ...ref, ...data };

/* eslint-disable no-param-reassign */
const ordered = Object.keys(initialState).reduce((obj: any, key) => {
obj[key] = updated[key];
return obj;
}, {});
/* eslint-enable no-param-reassign */

store.setState({
refs: updated,
refs: ordered,
});
},
};
Expand Down

0 comments on commit a24616a

Please sign in to comment.