question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Addon-docs: Support CSF3 play function

See original GitHub issue

As a user, I’d like to see stories that use play functions to achieve interactions the same on the Docs page as how it appears on the Storybook Canvas.

Storybook CSF3 adds a play function for scripted interaction with components after a story has rendered. This currently does not work in the docs tab. We need to make it work:

  • For iframe stories
  • For inline stories

There are a few different issues to deal with around dueling play functions and dueling focus.

Dueling play functions

Two play functions can’t run at the same time: their events will clobber one another, especially if they require focus, e.g. keyboard events.

One way to deal with this is to run play functions sequentially. This can be problematic for long-running play functions.

Another way to deal with it is to not run play functions on the Docs page at all, and have UI by which the user can run a play function.

Dueling focus

A related issue is dueling Focus. Even if a play function finishes instantaneously, if story A shows element A focused, and story B shows element B focused, then at most one of those stories can show correctly on the Docs page.

The sequential approach above won’t fix this. Only the play function UI, would work for this.

Proposal

Since the play function UI works for all cases, that’s a relatively simple solution.

Alternative

A more complex solution would be to make it configurable with a parameter, e.g.

parameters: {
  docs: {
    playFunction: true,
  }
}

And then sequentially play all stories with playFunction true. This way the CSF author has control and can set playFunction to false for long-running stories.

┆Issue is synchronized with this Asana task by Unito

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
ndelangencommented, Jul 23, 2021
const queries = within(container)

❤️

1reaction
shilmancommented, May 10, 2022

@bodograumann nope, unfortunately not. 7.0 🤞

Read more comments on GitHub >

github_iconTop Results From Across the Web

Play function - Storybook - JS.ORG
Play functions are small snippets of code executed after the story renders. Enabling you to interact with your components and test scenarios that...
Read more >
@storybook/addon-storyshots | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
CSF3: Default render functions for Svelte #15997 - Issuehunt
Svelte CSF is a "svelte-native" way to write stories. It compiles to CSF under the hood, but it's not actually CSF. Much like...
Read more >
@storybook/addon-docs: Versions | Openbase
Full version history for @storybook/addon-docs including change logs. ... Core: Fix ability to use component-level play functions #17817; CLI: Fix docsPage ...
Read more >
Source - GitHub
... CSF-tools: Support main.js default exports [#19738](https://github.com/storybooks/storybook/pull/19738) - Addon-docs: Disable play functions in docs ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found