Skip to content

Commit

Permalink
Merge pull request #18130 from quickgiant/quickgiant.canvas-current-s…
Browse files Browse the repository at this point in the history
…election-crash

Addon-docs: Fix Canvas block CURRENT_SELECTION handling
  • Loading branch information
shilman authored May 4, 2022
2 parents 45e37e4 + e53a3be commit ff00d58
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 ff00d58

Please sign in to comment.