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

Portable Stories: Fix injected root element changing layout #26387

Merged
merged 2 commits into from Mar 8, 2024

Conversation

JReinhold
Copy link
Contributor

@JReinhold JReinhold commented Mar 8, 2024

Closes #26368

What I did

In composeStory, instead of injecting a root element to serve as the default canvasElement for play-functions, we're now just relying on document.body instead, which should work in 99 % of use cases involving Vitest, Jest, Playwright, etc. For the edge cases where document.body isn't correct - eg. you're rendering the composed story deep in on a site, you're still able to overwrite the canvasElement by just passing an element to play().

cc @dannyhw this might not work for React Native, but AFAIK play-functions don't work at all in React Native, so this is probably an issue for the future? "Worst case" users can always pass a canvasElement.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This pull request has been released as version 0.0.0-pr-26387-sha-0dbe3e46. Try it out in a new sandbox by running npx storybook@0.0.0-pr-26387-sha-0dbe3e46 sandbox or in an existing project with npx storybook@0.0.0-pr-26387-sha-0dbe3e46 upgrade.

More information
Published version 0.0.0-pr-26387-sha-0dbe3e46
Triggered by @JReinhold
Repository storybookjs/storybook
Branch jeppe/composed-play-default-canvaselement
Commit 0dbe3e46
Datetime Fri Mar 8 13:40:48 UTC 2024 (1709905248)
Workflow run 8204148038

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=26387

@JReinhold JReinhold marked this pull request as ready for review March 8, 2024 13:39
Copy link

nx-cloud bot commented Mar 8, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 0dbe3e4. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@dannyhw
Copy link
Member

dannyhw commented Mar 8, 2024

Happy to test on RN if you have a canary or after release. Seems ok though.

Copy link
Member

@yannbf yannbf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! Thanks <3

@yannbf yannbf merged commit d369c9d into next Mar 8, 2024
56 checks passed
@yannbf yannbf deleted the jeppe/composed-play-default-canvaselement branch March 8, 2024 15:17
@github-actions github-actions bot mentioned this pull request Mar 8, 2024
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Storybook 8.0.0-rc.2 breaks styling of composed stories
3 participants