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

Fix rendering of design token previews in storybook #1028

Merged
merged 8 commits into from
Feb 14, 2023
Merged

Conversation

jattasNI
Copy link
Contributor

@jattasNI jattasNI commented Feb 6, 2023

Pull Request

🀨 Rationale

Fixes #714

πŸ‘©β€πŸ’» Implementation

The theme-aware tokens story tries to read token values from the CSS variables that are mirrored to the document's root <html> element. But at the time the story renders, not all of those variables have been populated yet. This is because some of the updates are queued in the FAST render queue. (I'm not sure exactly why some previews worked, but it appears that the tokens with constant default values are not readable while the ones with values generated by functions are available)

My fix is to call our processUpdates() async helper to flush the queue before reading token values.

πŸ§ͺ Testing

  • Verified that the bug reproduced locally before this change and no longer reproduces after it.
  • the Firefox snapshot in Chromatic also used to reproduce this bug but the build for this PR shows it now renders all previews

βœ… Checklist

  • I have updated the project documentation to reflect my changes or determined no changes are needed.

@jattasNI jattasNI marked this pull request as ready for review February 6, 2023 19:09
@jattasNI jattasNI merged commit 75652f9 into main Feb 14, 2023
@jattasNI jattasNI deleted the token-render-bug branch February 14, 2023 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Token previews intermittently not rendering for some types
2 participants