Skip to content

Commit

Permalink
fix: sidebar scroll navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jun 3, 2020
1 parent 3a55929 commit 1c08913
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ui/app-components/src/Navmenu/Navmenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,9 @@ export const Navmenu: FC<NavMenuProps> = ({
textDecoration: 'none',
cursor: 'pointer',
}}
onClick={() => {
onClick={(e: any) => {
if (items) {
e.stopPropagation();
onMenuChange(item, isExpanded);
} else if (typeof onSelect === 'function') {
onSelect(item);
Expand Down
6 changes: 5 additions & 1 deletion ui/app-components/src/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ export const Sidebar: FC<SidebarProps & BoxProps> = ({
return collapsed ? null : (
<Box sx={style} {...rest}>
<div
sx={{ position: !responsive ? 'fixed' : undefined }}
sx={{
position: !responsive ? 'fixed' : undefined,
height: '100%',
overflowY: 'auto',
}}
onClick={() => responsive && setCollapsed(true)}
>
<Flex
Expand Down
11 changes: 10 additions & 1 deletion ui/app/src/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ export const Sidebar: FC<SidebarProps> = ({ docPath, buttonClass, title }) => {

const docs: string[] = Object.keys(storeProvider.getDocs() || []);
const sortedDocs =
options && options.storySort ? docs.sort(options.storySort) : docs;
options && options.storySort
? docs.sort((a: string, b: string) => {
//@ts-ignore
const sort = options.storySort(a, b);
if (sort !== 0) {
return sort;
}
return docs.indexOf(a) - docs.indexOf(b);
})
: docs;
const menuItems = sortedDocs.reduce((acc: MenuItems, doc: string) => {
const levels = doc.split('/');
createMenuItem(levels, levels, acc);
Expand Down

0 comments on commit 1c08913

Please sign in to comment.