Skip to content

Commit

Permalink
Fix issue where Canvas block does not load CURRENT_SELECTION story
Browse files Browse the repository at this point in the history
  • Loading branch information
quickgiant committed May 3, 2022
1 parent 114a77c commit e53a3be
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion addons/docs/src/blocks/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { DocsContext, DocsContextProps } from './DocsContext';
import { SourceContext, SourceContextProps } from './SourceContainer';
import { getSourceProps, SourceState } from './Source';
import { useStories } from './useStory';
import { CURRENT_SELECTION } from './types';

export { SourceState };

Expand Down Expand Up @@ -53,7 +54,10 @@ const getPreviewProps = (
);
const sourceProps = getSourceProps({ ids: targetIds }, docsContext, sourceContext);
if (!sourceState) sourceState = sourceProps.state;
const stories = useStories(targetIds, docsContext);
const storyIds = targetIds.map((targetId) =>
targetId === CURRENT_SELECTION ? docsContext.id : targetId
);
const stories = useStories(storyIds, docsContext);
isLoading = stories.some((s) => !s);

return {
Expand Down

0 comments on commit e53a3be

Please sign in to comment.