storybook-addon-pseudo-states 1.15.2--canary.f030ea1.0 → 1.15.2--canary.46.5e95e86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -67,9 +67,11 @@ const withPseudoState = (StoryFn, _ref2) => {
|
|
|
67
67
|
const {
|
|
68
68
|
pseudo: globals
|
|
69
69
|
} = globalsArgs;
|
|
70
|
-
const canvasElement =
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
const canvasElement = (0, _addons.useMemo)(() => {
|
|
71
|
+
viewMode === "docs" ? document.getElementById(`story--${id}`) : document.getElementById("storybook-root") ||
|
|
72
|
+
// Storybook 7.0+
|
|
73
|
+
document.getElementById("root");
|
|
74
|
+
}, [viewMode, id]);
|
|
73
75
|
|
|
74
76
|
// Sync parameter to globals, used by the toolbar (only in canvas as this
|
|
75
77
|
// doesn't make sense for docs because many stories are displayed at once)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-env browser */
|
|
2
|
-
import { addons, useEffect } from "@storybook/addons";
|
|
2
|
+
import { addons, useEffect, useMemo } from "@storybook/addons";
|
|
3
3
|
import { DOCS_RENDERED, STORY_CHANGED, STORY_RENDERED, UPDATE_GLOBALS } from "@storybook/core-events";
|
|
4
4
|
import { PSEUDO_STATES } from "./constants";
|
|
5
5
|
import { rewriteStyleSheet } from "./rewriteStyleSheet";
|
|
@@ -60,9 +60,11 @@ export const withPseudoState = (StoryFn, _ref2) => {
|
|
|
60
60
|
const {
|
|
61
61
|
pseudo: globals
|
|
62
62
|
} = globalsArgs;
|
|
63
|
-
const canvasElement =
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
const canvasElement = useMemo(() => {
|
|
64
|
+
viewMode === "docs" ? document.getElementById(`story--${id}`) : document.getElementById("storybook-root") ||
|
|
65
|
+
// Storybook 7.0+
|
|
66
|
+
document.getElementById("root");
|
|
67
|
+
}, [viewMode, id]);
|
|
66
68
|
|
|
67
69
|
// Sync parameter to globals, used by the toolbar (only in canvas as this
|
|
68
70
|
// doesn't make sense for docs because many stories are displayed at once)
|