storybook icon indicating copy to clipboard operation
storybook copied to clipboard

Addon-docs: DocsPage Controls don't update iframe stories

Open shilman opened this issue 4 years ago • 22 comments

Controls don't update iframed stories on the Docs tab, but do update on the Canvas tab.

controls-bug

For frameworks that support inline rendering (react, vue, web-components, etc.), making the docs stories render inline is a workaround.

shilman avatar Aug 11 '20 23:08 shilman

i was experiencing something similar to this with react

michaelbayday avatar Aug 12 '20 16:08 michaelbayday

I've been observing controls not updating the render on the canvas tab, with react

petermikitsh avatar Aug 12 '20 18:08 petermikitsh

@michaelbayday @petermikitsh do either of you have a repro you can share? haven't seen that yet.

shilman avatar Aug 12 '20 18:08 shilman

@shilman

9WZt9d1cgN

reproduced in vue, here https://github.com/storybookjs/storybook/issues/11990

blowsie avatar Aug 14 '20 14:08 blowsie

Reproduction is now showing the controls and showing the issue https://github.com/blowsie/storybook-vue

blowsie avatar Aug 14 '20 16:08 blowsie

The problem is the story:

https://github.com/blowsie/storybook-vue/blob/master/src/TestComponent.stories.js#L11

Try:

const Template = (args, { argTypes }) => ({

shilman avatar Aug 14 '20 16:08 shilman

Fixed my issue, thanks!

blowsie avatar Aug 14 '20 16:08 blowsie

@shilman No repro; my observation was a hiccup on my upgrade from 5 to 6. My apologies!

petermikitsh avatar Aug 17 '20 19:08 petermikitsh

So for me i also have this issue with angular -> here is an example repo: https://github.com/flobiber/storybook-angular

flobiber avatar Aug 25 '20 08:08 flobiber

Can be observed here as well: https://storybookjs.netlify.app/angular-cli/?path=/docs/docbutton--basic

manuelmeister avatar Sep 21 '20 09:09 manuelmeister

Scouring around, this workaround got my Docs page re-rendering with changes to controls (for React implementations, but perhaps could also work for Vue?):

import { parameters } from "@storybook/addon-docs/dist/frameworks/react/config";
import { addParameters } from '@storybook/react';
import { DocsPage, DocsContainer } from '@storybook/addon-docs/blocks';

addParameters({
  docs: {
    ...parameters.docs,
    container: DocsContainer,
    page: DocsPage,
  },
  controls: {
    expanded: true,
  }
});

Note the import and spread of parameters.docs

jamesjenkinsjr avatar Sep 21 '20 18:09 jamesjenkinsjr

@jamesjenkinsjr if you needed to do this it's due to a configuration problem and not related to the iframe issue here. I just want to clarify for anybody who stumbles across this to avoid confusion.

shilman avatar Sep 21 '20 18:09 shilman

with this PR it will work https://github.com/storybookjs/storybook/pull/13525

ThibaudAV avatar Jan 22 '21 16:01 ThibaudAV

Hi! I'm experiencing this issue with Angular + iframes. I see #13525 was already merged and it should've fixed this. There's no one else having this problem any more? Maybe it's something on my side?

lucas-labs avatar Sep 11 '21 16:09 lucas-labs

@lucas-labs you need to opt into inline rendering by configuring .storybook/preview.js:

export const parameters = { docs:  { inlineStories: true } };

shilman avatar Sep 11 '21 16:09 shilman

@lucas-labs I have this problem too.

@shilman but if we have a component taking the whole page as popin for example ? with that I can't render inline and controls are still not working with iframes.

dmartinjs avatar Sep 13 '21 12:09 dmartinjs

@dmartinjs that's kind of my situation too. In my case, the component is not taking the whole page, but it's a static header stuck to the top, and since I have several stories, using inline components causes all my stories to render one on top of each other taking the same space in the docs page.

lucas-labs avatar Sep 13 '21 13:09 lucas-labs

Same problem in Vue. :/

RenanRossiDias avatar Sep 22 '21 14:09 RenanRossiDias

I found a partial solution to deal with this by disabling iframe and using decorators to set a height and use the transform: scale(1) trick to have the component only render in the story.

So for example in my Story (in web component context):

export default {
  title: 'Indicators/Toast',
  decorators: [(story) => html`<div style="height: 100vh;transform: scale(1);">${story()}</div>`],
}

dmartinjs avatar Dec 29 '21 14:12 dmartinjs

@lucas-labs you need to opt into inline rendering by configuring .storybook/preview.js:

export const parameters = { docs:  { inlineStories: true } };

Stumbled upon this too (docs not updating on input changes, but canvas does), and this fixes the issue with import { addParameters } from '@storybook/angular';.

Shouldn't it be made the default for Angular (and/or other frameworks?)? What are the drawbacks?

qortex avatar Jan 19 '22 15:01 qortex

Im facing the same issue. Not only the controls but also the global context does NOT work properly in Docs page.

tannguyenad avatar Mar 25 '22 06:03 tannguyenad

@lucas-labs you need to opt into inline rendering by configuring .storybook/preview.js:

export const parameters = { docs:  { inlineStories: true } };

Shouldn't it be made the default for Angular (and/or other frameworks?)? What are the drawbacks?

@qortex Apparently it's deliberately set to false by default for Angular. Not sure what are the drawbacks, though... https://github.com/storybookjs/storybook/pull/14447

EliezerB123 avatar Aug 16 '22 11:08 EliezerB123

Hello, everybody. I'm facing the same issue using parameter - docs: { page: DocsPage, inlineStories: false, iframeHeight: 500 } (Framework - React). Am i right that the only option is to switch inlineStories to true. And how can we solve that if we need to render component in iframe. @shilman

SushkaVlad avatar Nov 01 '22 13:11 SushkaVlad

@SushkaVlad you're correct that's the only option for now

@tmeasday will any of the recent docs rearchitecture address this limitation of addon-docs custom useArgs hook for iframed stories?

shilman avatar Nov 01 '22 13:11 shilman

@shilman Thanks a lot)

SushkaVlad avatar Nov 01 '22 20:11 SushkaVlad

@shilman I don't think we've changed the implementation, but then again it uses the channel so it's not clear to me why it wouldn't work. Probably something we should look at while we revisit the ArgsTable component cc @JReinhold

tmeasday avatar Nov 01 '22 22:11 tmeasday

Oh, is the issue that we have a preview embedded inside a preview and messages aren't making it three layers deep? I guess that's probably the problem, scratch what I just said above.

I don't think anything we are doing will influence this problem. It's sort of orthogonal to everything else.

tmeasday avatar Nov 01 '22 22:11 tmeasday

Hi, I saw that @shilman closed my bug ticket in #22148, is a fix being planned?

quantizor avatar May 03 '23 15:05 quantizor

@probablyup it's not something that's actively being worked on. But would be happy to support someone working on it.

tmeasday avatar May 04 '23 00:05 tmeasday

I could take a crack at it with a bit of guidance

quantizor avatar May 04 '23 01:05 quantizor