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

[WNMGDS-3077] Fix wrong Storybook iframes loading on doc site #3357

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

pwolfert
Copy link
Collaborator

Summary

Apply the client-side-only fix to story iframes to fix rehydration issue. This is the same workaround that we used in #2962. Making it client-side only means there is no mismatched HTML for Gatsby to try to reconcile, so it'll always show the right one. There's really no reason to pre-render that component anyway.

Unfortunately this fix does not retroactively fix earlier versions of the doc site, so if we want to fix older archived versions, we have to go back and apply the fix to those versions and redeploy.

How to test

To reproduce the original issue on the main branch:

  1. yarn build:docs
  2. yarn serve:docs
  3. Navigate to http://localhost:9000/components/alert/?theme=medicare
  4. Take a look at the first storybook example. Notice that even though this is the Medicare theme, it shows the info alert of the core theme. If you inspect the iframe in the page, you'll notice its url is wrong. It's pointing to the core theme in Storybook even though the client-side JavaScript that loads knows the correct theme and url to load. It's that Gatsby doesn't correctly reconcile the statically generated HTML with the new HTML being rendered in the client.

Checklist

  • Prefixed the PR title with the Jira ticket number as [WNMGDS-####] Title or [NO-TICKET] if this is unticketed work.
  • Selected appropriate Type (only one) label for this PR, if it is a breaking change, label should only be Type: Breaking
  • Selected appropriate Impacts, multiple can be selected.
  • Selected appropriate release milestone

This is the same workaround that we used in [#2962](https://github.com/CMSgov/design-system/pull/2962/files).

To reproduce the original issue on the main branch:

1. `yarn build:docs`
2. `yarn serve:docs`
3. Navigate to http://localhost:9000/components/alert/?theme=medicare
4. Take a look at the first storybook example. Notice that even though this is the Medicare theme, it shows the info alert of the core theme. If you inspect the iframe in the page, you'll notice its url is wrong. It's pointing to the core theme in Storybook even though the client-side JavaScript that loads knows the correct theme and url to load. It's that Gatsby doesn't correctly reconcile the statically generated HTML with the new HTML being rendered in the client.
@pwolfert pwolfert added Type: Fixed Indicates an unexpected problem or unintended behavior Impacts: Documentation Indicates that this item relates to documentation labels Dec 17, 2024
@pwolfert pwolfert added this to the 12.1.0 milestone Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Impacts: Documentation Indicates that this item relates to documentation Type: Fixed Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant