Storybook: Addon centered breaks story display in Docs mode

Created on 23 Mar 2020  路  2Comments  路  Source: storybookjs/storybook

Describe the bug
When adding addDecorator(centered) to preview.js, the display of the story in the Docs tab is silently ignored and I am instead presented with a blank slate.

To Reproduce
Append addDecorator(centered) to preview.js as is done here:

import { addDecorator, addParameters } from '@storybook/react'
import { withA11y } from '@storybook/addon-a11y'
import centered from '@storybook/addon-centered/react'

import '../src/Styles/_global.scss'

addDecorator(centered)
addDecorator(withA11y)

addParameters({
  backgrounds: [
    { name: 'light', value: '#eff0f9', default: true },
    { name: 'dark', value: '#392b64' },
  ],
})

Expected behavior
The component should render, ideally centered, even when embedded in the Docs page.

Screenshots
If applicable, add screenshots to help explain your problem.

Canvas with centered :100:
image

Docs with centered 馃憥
image

Canvas without centered 馃憥
image

Docs without centered 馃挴
image

System:
Environment Info:

System:
OS: Windows 10 10.0.18362
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
Node: 12.16.1 - C:\Program Files\nodejs\node.EXE
npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 44.18362.449.0

Additional context
Potential workaround: apply addon-centered only to Canvas tab. Is this easily achievable?

centered docs bug

All 2 comments

@jgarplind starting in storybook 6.0 we're deprecating addon centered and we have a built-in layout parameter that controls the layout:

https://github.com/storybookjs/storybook/blob/next/examples/official-storybook/stories/core/layout.stories.js

Give that a try?

Closing as dupe to #7227

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joeruello picture joeruello  路  79Comments

dependencies[bot] picture dependencies[bot]  路  142Comments

hansthinhle picture hansthinhle  路  57Comments

bpeab picture bpeab  路  70Comments

moimikey picture moimikey  路  67Comments