Decorators on stories are placed around the inline-view of the info-addon
See original GitHub issueI’m trying to use a combination of the Info-addon with inline: true and a decorator that limits the width of my component to X pixels.
What I currently have is
import { storiesOf } from '@storybook/react';
import { withInfo } from '@storybook/addon-info';
storiesOf('MyComponent', module)
.addDecorator(story => (
<div style={{ width: 300, margin: '1em' }}>
{story()}
</div>
))
.add('Instance',
withInfo({
text: 'A descriptive test',
inline: true,
})(() => (
<MyComponent />
)));
What I expected was that the inline info (header + source + prop-tables) was rendered in full width, and only MyComponent was wrapped in the decorator limiting its width to 300px.
However, the decorator is applied around the entire inline info view, also limiting the width of the header, source and prop-table.
The markup that ends up being inserted is the following:
<div data-reactroot="" style="width: 300px; margin: 1em;">
<div>
<div><!-- the info-addon header --></div>
<!-- my component -->
<div><!-- the info-addon source + prop-table --></div>
</div>
</div>
What I was expecting was something like
<div>
<div><!-- the info-addon header --></div>
<div style="width: 300px; margin: 1em;">
<!-- my component -->
</div>
<div><!-- the info-addon source + prop-table --></div>
</div>
Is there a way to use decorators to only decorate the component, and not the inline view too?
As far as I remember, the old addWithInfo-API didn’t have the same problem/behaviour.
Versions: storybook/addon-info = ^3.2.9, storybook/react = ^3.2.8
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:8 (2 by maintainers)

Top Related StackOverflow Question
I am also experiencing the same issue. I wrap some of my components in divs with set width and it’s affecting the addon.
At this stage
withInfois exactly the same decorator as any other you adding withaddDecorator. It just works with astoryprop passed to him.storycould be wrapped to another decorator, butwithInfohas no information about that.I guess better to say that it should be the
rootdecorator (actually the last one because each decorator wraps all previous)