From b83fcb229189d3dd71dc074e1744bffe0c4e4346 Mon Sep 17 00:00:00 2001 From: dariadomagala Date: Fri, 28 Oct 2022 11:16:05 +0200 Subject: [PATCH 1/2] feat: add compact option to product menu, remove console errors --- .storybook/custom/components/DocsPage.js | 2 +- src/Shellbar/Shellbar.js | 56 ++++++++++++++++++-- src/Shellbar/__stories__/Shellbar.stories.js | 1 + src/SideNavigation/_SideNavListItem.js | 6 +-- 4 files changed, 57 insertions(+), 8 deletions(-) diff --git a/.storybook/custom/components/DocsPage.js b/.storybook/custom/components/DocsPage.js index b8d55434a..d1760f67b 100644 --- a/.storybook/custom/components/DocsPage.js +++ b/.storybook/custom/components/DocsPage.js @@ -80,7 +80,7 @@ const DocsPage = () => { Examples - {stories.map((story) => story && story && } + {productSwitch && productSwitch.compact && ( + + + {productSwitchList.map((item, index) => { + return ( + + {item.glyph && ( + <> + +     + + )} + {item.title} + + ); + })} + + + ) + } + control={ + + } + noArrow + popperProps={{ id: `${cssNamespace}-shellbar-product-popover` }} /> + )} {profile && (
@@ -451,7 +497,7 @@ class Shellbar extends Component {
)} - {productSwitch && ( + {productSwitch && !productSwitch.compact && (
( }} productMenu={productMenu} productSwitch={{ + compact: false, label: 'Product Switch' }} productSwitchList={[ diff --git a/src/SideNavigation/_SideNavListItem.js b/src/SideNavigation/_SideNavListItem.js index e32f70f3d..3fd9dd909 100644 --- a/src/SideNavigation/_SideNavListItem.js +++ b/src/SideNavigation/_SideNavListItem.js @@ -60,7 +60,7 @@ class SideNavListItem extends React.Component { href={url} onClick={!hasChild ? (e) => { !hasChild && onClick(e); - onItemSelect(e, id, hasChild); + if (onItemSelect) onItemSelect(e, id, hasChild); } : null}> {glyph ? ( { /* eslint-disable jsx-a11y/no-noninteractive-tabindex */ onClick(e); - onItemSelect(e, id, hasChild); + if (onItemSelect) onItemSelect(e, id, hasChild); }}> {link}