Skip to content

Commit

Permalink
fix: autoselect doc page first story if none
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jun 6, 2020
1 parent acadb8f commit 33f5585
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ui/app-components/src/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const Sidebar: FC<SidebarProps & BoxProps> = ({
bottom: 0,
};
return collapsed ? null : (
<Box tabIndex={0} sx={style} {...rest}>
<Box sx={style} {...rest}>
<div
sx={{
position: !responsive ? 'fixed' : undefined,
Expand Down
16 changes: 11 additions & 5 deletions ui/blocks/src/context/block/BlockContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,33 @@ export const BlockContext = React.createContext<BlockContextProps>({});

export const BlockContextProvider: React.FC<BlockContextInputProps> = ({
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 (
<ErrorBoundary>
<RecoilRoot>
<BlockContext.Provider
value={{
storyId,
docId: pageId,
docId,
storeProvider: store,
options,
}}
>
<BlockDataContextProvider
store={store}
storyId={storyId}
docId={pageId}
docId={docId}
>
<BlockControlsContextProvider store={store}>
{children}
Expand Down

0 comments on commit 33f5585

Please sign in to comment.