Skip to content

Commit

Permalink
fix: docId context
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jul 6, 2020
1 parent b5e78cc commit 65eec8e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ui/app/src/DocPage/DocPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const DocPage: FC<Omit<DocPageProps, 'doc'>> = ({
}) => {
const { storeProvider, docId } = useContext(BlockContext);
const doc = docId ? storeProvider.getStoryDoc(docId) : undefined;

const hasNoSideBars = doc && !doc.navSidebar && !doc.contextSidebar;
const isFullPage = doc && doc.fullPage;
if (hasNoSideBars || isFullPage) {
Expand All @@ -26,5 +27,5 @@ export const DocPage: FC<Omit<DocPageProps, 'doc'>> = ({
/>
);
}
return doc ? <SidebarsPage type={type} doc={doc} {...props} /> : null;
return <SidebarsPage type={type} {...props} />;
};
5 changes: 4 additions & 1 deletion ui/app/src/SidebarsPage/SidebarsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { BlockContext } from '@component-controls/blocks';
import { SidebarsMDXPage } from './SidebarsMDXPage';
import { DocPageProps, SidebarsStoryPage } from './SidebarsStoryPage';

export const SidebarsPage: FC<DocPageProps> = ({ type, activeTab }) => {
export const SidebarsPage: FC<Omit<DocPageProps, 'doc'>> = ({
type,
activeTab,
}) => {
const { storeProvider, docId } = useContext(BlockContext);
const doc = docId ? storeProvider.getStoryDoc(docId) : undefined;
if (doc && doc.MDXPage && !doc.stories?.length) {
Expand Down
4 changes: 2 additions & 2 deletions ui/blocks/src/context/block/BlockContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ export const BlockContextProvider: React.FC<BlockContextInputProps> = ({
<BlockContext.Provider
value={{
storyId,
docId,
docId: propsDocId,
storeProvider: store,
options,
}}
>
<BlockDataContextProvider
store={store}
storyId={storyId}
docId={docId}
docId={propsDocId}
>
{children}
</BlockDataContextProvider>
Expand Down

0 comments on commit 65eec8e

Please sign in to comment.