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

Bug: blank page when a ref is missing but specified in url #21598

Merged
merged 2 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions code/lib/manager-api/src/modules/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ export const init: ModuleFn<SubAPI, SubState, true> = ({
},
resolveStory: (storyId, refId) => {
const { refs, index } = store.getState();
if (refId && !refs[refId]) {
return null;
}
if (refId) {
return refs[refId].index ? refs[refId].index[storyId] : undefined;
}
Expand Down
6 changes: 3 additions & 3 deletions code/ui/manager/src/components/preview/FramesRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { IFrame } from './iframe';
import type { FramesRendererProps } from './utils/types';
import { stringifyQueryParams } from './utils/stringifyQueryParams';

const getActive = (refId: FramesRendererProps['refId']) => {
if (refId) {
const getActive = (refId: FramesRendererProps['refId'], refs: FramesRendererProps['refs']) => {
if (refId && refs[refId]) {
return `storybook-ref-${refId}`;
}

Expand Down Expand Up @@ -55,7 +55,7 @@ export const FramesRenderer: FC<FramesRendererProps> = ({
...queryParams,
...(version && { version }),
});
const active = getActive(refId);
const active = getActive(refId, refs);

const styles = useMemo<CSSObject>(() => {
// add #root to make the selector high enough in specificity
Expand Down