Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
shilman opened this issue Aug 11, 2020 · 45 comments
Open

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

shilman opened this issue Aug 11, 2020 · 45 comments

Comments

@shilman
Copy link
Member

shilman commented Aug 11, 2020

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.

@michaelbayday
Copy link

i was experiencing something similar to this with react

@petermikitsh
Copy link
Contributor

petermikitsh commented Aug 12, 2020

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

@shilman
Copy link
Member Author

shilman commented Aug 12, 2020

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

@blowsie
Copy link

blowsie commented Aug 14, 2020

@shilman

9WZt9d1cgN

reproduced in vue, here
#11990

@blowsie
Copy link

blowsie commented Aug 14, 2020

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

@shilman
Copy link
Member Author

shilman commented Aug 14, 2020

The problem is the story:

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

Try:

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

@blowsie
Copy link

blowsie commented Aug 14, 2020

Fixed my issue, thanks!

@petermikitsh
Copy link
Contributor

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

@shilman shilman changed the title Addon-docs: Controls don't update iframe stories Addon-docs: DocsPage Controls don't update iframe stories Aug 18, 2020
@flobiber
Copy link

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

@stale stale bot added the inactive label Sep 20, 2020
@manuelmeister
Copy link
Contributor

@stale stale bot removed the inactive label Sep 21, 2020
@shilman shilman added the todo label Sep 21, 2020
@storybookjs storybookjs deleted a comment from stale bot Sep 21, 2020
@jamesjenkinsjr
Copy link

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

@shilman
Copy link
Member Author

shilman commented Sep 21, 2020

@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.

@valentinpalkovic
Copy link
Contributor

I am closing this because it works appropriately in Storybook 7. Please feel free to reopen it with a reproduction on Stackblitz (https://storybook.new)

@quantizor
Copy link

I am closing this because it works appropriately in Storybook 7.

It doesn't, at least in storystore v6 mode

@quantizor
Copy link

quantizor commented May 8, 2023

I think the simplest way to do that would be to augment @storybook/channel-postmessage to simply do that "forwarding to subframes" when this.config.page === 'preview'. Does that make sense?

This makes sense to me... perhaps it should only be to the primary story, since that's what the Controls block is typically affecting?

Edit: unless the message already has the story ID encoded so the story itself knows to not update if the message sent doesn't match

@valentinpalkovic
Copy link
Contributor

@probablyup could you provide a simple reproduction on stackblitz? https://storybook.new

@valentinpalkovic valentinpalkovic changed the title Addon-docs: DocsPage Controls don't update iframe stories Addon-docs: DocsPage Controls don't update iframe stories in StoryStore v6 mode May 8, 2023
@quantizor
Copy link

quantizor commented May 8, 2023

@probablyup could you provide a simple reproduction on stackblitz? https://storybook.new

Here you go: https://stackblitz.com/edit/github-yxuht3?file=src%2Fstories%2FButton.tsx,src%2Fstories%2FButton.stories.ts&preset=node

If you go to the Buttons "Docs" story you can see that I added the following to the meta config:

parameters: {
  docs: {
    story: {
      inline: false,
    },
  },
},

After adding this, changing the controls for the primary story has no effect.

@tmeasday
Copy link
Member

tmeasday commented May 9, 2023

@valentinpalkovic I believe this issue affects v7 mode also.

@tmeasday
Copy link
Member

tmeasday commented May 9, 2023

I think the simplest way to do that would be to augment @storybook/channel-postmessage to simply do that "forwarding to subframes" when this.config.page === 'preview'. Does that make sense?

This makes sense to me... perhaps it should only be to the primary story, since that's what the Controls block is typically affecting?

I don't think we can or should be that specific in the forwarding, I think we should just forward every message on from the manager -> sub previews. Otherwise it'll be confusing (and harder to do!).

Edit: unless the message already has the story ID encoded so the story itself knows to not update if the message sent doesn't match

That's correct. The storyId is encoded in the message.

@valentinpalkovic valentinpalkovic changed the title Addon-docs: DocsPage Controls don't update iframe stories in StoryStore v6 mode Addon-docs: DocsPage Controls don't update iframe stories May 9, 2023
@ndelangen
Copy link
Member

I think the simplest way to do that would be to augment @storybook/channel-postmessage to simply do that "forwarding to subframes" when this.config.page === 'preview'. Does that make sense?

Yes, that makes sense @tmeasday

@shilman shilman removed the todo label Jun 20, 2023
@seriouz
Copy link
Contributor

seriouz commented Jul 18, 2023

We also ran into the problem today. Is a quick fix available?

@ndelangen
Copy link
Member

No quick fix yet @seriouz

@asso1985
Copy link

Any news on this? Facing same issue.

@jyang81
Copy link

jyang81 commented Dec 15, 2023

I'm also facing this issue. I need to set the iframe height for my stories, but because of the inline: false the controls do not update the story.

parameters: {
    docs: {
      story: {
        inline: false,
        iframeHeight: 300
      }
    }
  }

Is there any other way to set the iframe height?

@mojabyte
Copy link

I'm also facing this issue. I need to set the iframe height for my stories, but because of the inline: false the controls do not update the story.

parameters: {
    docs: {
      story: {
        inline: false,
        iframeHeight: 300
      }
    }
  }

Is there any other way to set the iframe height?

If you want to set the height of the story preview only without setting the inline: false, you can use the docs.story.height parameter:

{
  parameters: {
    docs: {
      story: {
        height: '300px'
      }
    }
  }
}

@kerryj89
Copy link

kerryj89 commented Jan 13, 2024

I noticed Storybook styles colliding into the inline stories, so I then thought to use the iframe mode to prevent that. And now I'm faced with the realization that controls do not working with iframe stories in docs page.

I've created a PR that would let users know of this current iframe stories + docs + controls limitation in the docs #25593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Empathy Backlog
Development

No branches or pull requests