Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion code/core/src/viewport/useViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ export const useViewport = () => {
}, [storyGlobals, update]);

useEffect(() => {
// Skip if parameter not loaded to avoid race condition with default MINIMAL_VIEWPORTS
if (!parameter) {
return;
}

// Reset the viewport to the story global value if the URL state defines an invalid option
if (option) {
if (Object.hasOwn(options, option)) {
Expand All @@ -203,7 +208,7 @@ export const useViewport = () => {
update(normalizeGlobal(storyGlobals?.[PARAM_KEY], false));
}
}
}, [storyGlobals, options, option, update]);
}, [parameter, storyGlobals, options, option, update]);

useEffect(() => {
api.setAddonShortcut(ADDON_ID, {
Expand Down
Loading