storybook: [addon-docs]: story-level viewMode specifier not working

Describe the bug Maybe this is to be expected, but if I have --docs flag on, viewMode doesn’t seem to be respected

To Reproduce Steps to reproduce the behavior:

  1. run with --docs
  2. set one story with parameters { viewMode: ‘story’ }
  3. navigate to that story
  4. See error (it renders with docs mode)

Expected behavior I expect, that if I run --docs, and I explicitly set the viewMode to story, it should render the iframe with viewMode=story.

Code snippets .storybook/preview.js

addParameters({
  viewMode: 'docs'
})

Button.stories.js

// CSF
export default {
  title: 'Button',
  component: Button,
  parameters: {
    // reset the view mode to "story" whenever the user navigates to this story
    viewMode: 'story',
  },
}

System: Environment Info:

System: OS: macOS 10.15.2 CPU: (16) x64 Intel® Core™ i9-9980HK CPU @ 2.40GHz Binaries: Node: 10.16.0 - /usr/local/bin/node Yarn: 1.21.1 - ~/.yarn/bin/yarn npm: 6.13.6 - /usr/local/bin/npm Browsers: Chrome: 79.0.3945.130 Safari: 13.0.4

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 16 (10 by maintainers)

Most upvoted comments

Hmm. 🤔 Well that part’s a bug then 😅

I can reproduce the issue as well with the following story:

export default {
  title: 'Whatever',
  parameters: {
    viewMode: 'story',
  },
};

If I’m currently browsing Storybook in docs and I go to this story, the view is not switched to “story”.

Would be good to get this fixed! I can take a look if someone can point me in the right direction?