Skip to content

fix copy button ssr bug#203

Merged
chriswhong merged 1 commit intomainfrom
fix-copy-button-ssr
Jan 19, 2023
Merged

fix copy button ssr bug#203
chriswhong merged 1 commit intomainfrom
fix-copy-button-ssr

Conversation

@chriswhong
Copy link
Copy Markdown
Contributor

Fixes a bug we encountered while attempting to upgrade dr-ui to use the latest version of mr-ui.

The CopyButton component makes use of clipboard.js which expects to run in the browser and references document. When attempting to build the dr-ui docs, batfish attempts to create static pages and the build fails while trying to render static content for CodeSnippet, which uses CopyButton.

CodeSnippet actually does a check for isCopySupported() before attempting to render CopyButton, so this is an ideal place to also check whether the code is running in a browser.

With this change, if there is no browser CopyButton.isCopySupported() returns false, CopyButton is never rendered, and SSR can proceed without issue.

@chriswhong chriswhong requested a review from tristen January 19, 2023 22:17
Copy link
Copy Markdown
Member

@tristen tristen left a comment

Choose a reason for hiding this comment

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

Sounds like a reasonable change to me!

@chriswhong chriswhong merged commit d14bdad into main Jan 19, 2023
@chriswhong chriswhong deleted the fix-copy-button-ssr branch January 19, 2023 22:31
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.

2 participants