From 33f55853d6dbcdb746e7d7b5d0665569cc21e0d8 Mon Sep 17 00:00:00 2001 From: atanasster Date: Sat, 6 Jun 2020 12:34:56 -0400 Subject: [PATCH] fix: autoselect doc page first story if none --- ui/app-components/src/Sidebar/Sidebar.tsx | 2 +- ui/blocks/src/context/block/BlockContext.tsx | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ui/app-components/src/Sidebar/Sidebar.tsx b/ui/app-components/src/Sidebar/Sidebar.tsx index 106b263fb..68fd16e25 100644 --- a/ui/app-components/src/Sidebar/Sidebar.tsx +++ b/ui/app-components/src/Sidebar/Sidebar.tsx @@ -71,7 +71,7 @@ export const Sidebar: FC = ({ bottom: 0, }; return collapsed ? null : ( - +
({}); export const BlockContextProvider: React.FC = ({ children, - storyId, - docId, + storyId: propsStoryId, + docId: propsDocId, store, options, }) => { - const pageId = storyId || docId ? docId : store.firstDoc; + let storyId = propsStoryId; + const docId = storyId || propsDocId ? propsDocId : store.firstDoc; + if (!storyId && docId) { + const doc = store.getStoryDoc(docId); + storyId = doc && doc.stories.length ? doc.stories[0] : undefined; + } + return ( = ({ {children}