storybook
storybook copied to clipboard
[Bug]: storySort is never called, sort has not effect
Describe the bug
The options.storySort
option is ignored.
To Reproduce
Here is my preview.cjs
file:
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
options: {
storySort: (a, b) => {
console.log(a, b);
return a[1].kind === b[1].kind ? 0 : a[1].id.localeCompare(b[1].id, undefined, { numeric: true });
}
},
};
console.log(parameters);
The sort has not effect, proof is that console.log(parameters);
is well printed but the console.log
from storySort
is not.
I also tried using options.storySort.order
with hard-coded array but it does not work too.
Here are the dependencies defined in package.json
:
"@storybook/addon-actions": "6.5.15",
"@storybook/addon-essentials": "6.5.15",
"@storybook/addon-interactions": "6.5.15",
"@storybook/addon-links": "6.5.15",
"@storybook/builder-vite": "0.2.6",
"@storybook/preset-scss": "1.0.3",
"@storybook/react": "6.5.15",
"@storybook/testing-library": "0.0.13",
For more context, here is the current sidebar:

System
System:
OS: macOS 13.0.1
CPU: (10) arm64 Apple M1 Pro
Binaries:
Node: 16.19.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 8.19.3 - /usr/local/bin/npm
Browsers:
Chrome: 109.0.5414.87
Safari: 16.1
Additional context
No response
Ok got it, I renamed preview.cjs
to preview.js
and it works now.
But I will be happy to understand how this could affect the sorting behavior ?
Yes, because Storybook is expecting preview.@(js|jsx|ts|tsx)
. I have created #20718 to handle the processing better.
Gadzooks!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-rc.5 containing PR #21637 that references this issue. Upgrade today to the @next
NPM tag to try it out!
npx sb@next upgrade --prerelease