Skip to content

Commit

Permalink
fix(ui): reset params set by de story after switching to another one
Browse files Browse the repository at this point in the history
  • Loading branch information
itsjavi committed Sep 1, 2023
1 parent d1baef9 commit 78bc46e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/storylite/src/components/canvas/CanvasIframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export function CanvasIframe(props: CanvasIframeProps) {
}

const story = stories.get(storyId)
if (story && story.parameters) {
const hasParams = Object.keys(story?.parameters ?? {}).length > 0

if (story && hasParams) {
// If the story has parameters, set them when the iframe loads
setParameters(
{
Expand All @@ -58,7 +60,7 @@ export function CanvasIframe(props: CanvasIframeProps) {
)

return () => {
setParameters(currentParams)
setParameters(currentParams, { crossWindow: true, persist: false })
}
}
}, [storyId, stories, iframeState.loaded, iframeState.iframe])
Expand Down

0 comments on commit 78bc46e

Please sign in to comment.