Skip to content

Commit

Permalink
fix: Preventing multiple 'Open in CodeSandbox' buttons being added wh…
Browse files Browse the repository at this point in the history
…en switching themes (microsoft#29932)

* fix: Preventing multiple 'Open in CodeSandbox' buttons being added when switching themes.

* Testing for all possible options, and not only for CodeSandbox.

* Addressing PR feedback.
  • Loading branch information
khmakoto committed Nov 29, 2023
1 parent b8ab0fa commit 69b1d23
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ export function prepareSandboxContainer(context: StoryContext) {

const classList = (showCodeButton.classList.value + ' with-code-sandbox-button').split(' ');

// this is needed in dev loop as every hot reload will add new buttons
if (process.env.NODE_ENV !== 'production') {
const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);
ourButtons.forEach(node => node.remove());
}
// remove button if it already existed
const ourButtons = container.querySelectorAll(`.with-code-sandbox-button`);
ourButtons.forEach(node => node.remove());

return {
container,
Expand Down

0 comments on commit 69b1d23

Please sign in to comment.