🎉
I found a workaround for making the viewMode persist to "docs" when navigating/opening the story group in the sidepanel in Storybook 6.5 (similar to the new behavior shown in Storybook 7)
Here is the decorator – any time the the viewMode changes back to 'story', it will re-select the story and trigger the correct viewMode as set in the story parameters (see below)
import { addons, useEffect } from '@storybook/addons';
import { SELECT_STORY } from '@storybook/core-events';
const withDocsRedirect = (Story, context) => {
const { id, viewMode } = context;
useEffect(() => {
if (viewMode !== 'docs') {
const channel = addons.getChannel();
channel.emit(SELECT_STORY, { storyId: id });
}
}, [viewMode]);
return Story();
};
Make sure your story has the following configured:
export const Docs = {
parameters: {
viewMode: 'docs',
},
decorators: [withDocsRedirect],
};