From 65840b17be0c935c8f4f0c32c45ebec009d75cfb Mon Sep 17 00:00:00 2001 From: Phil Kuang Date: Thu, 19 May 2022 17:00:50 -0400 Subject: [PATCH] fix(sidebarItem): only add arrow icon to items with a submenu Signed-off-by: Phil Kuang --- .changeset/mean-turtles-reply.md | 5 +++++ packages/core-components/src/layout/Sidebar/Items.tsx | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .changeset/mean-turtles-reply.md diff --git a/.changeset/mean-turtles-reply.md b/.changeset/mean-turtles-reply.md new file mode 100644 index 0000000000..f3b21989d1 --- /dev/null +++ b/.changeset/mean-turtles-reply.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-components': patch +--- + +Fix issue where right arrow icon was incorrectly added to side bar items without a sub-menu diff --git a/packages/core-components/src/layout/Sidebar/Items.tsx b/packages/core-components/src/layout/Sidebar/Items.tsx index c004f6904c..fde3c85c96 100644 --- a/packages/core-components/src/layout/Sidebar/Items.tsx +++ b/packages/core-components/src/layout/Sidebar/Items.tsx @@ -259,6 +259,7 @@ type SidebarItemBaseProps = { icon: IconComponent; text?: string; hasNotifications?: boolean; + hasSubmenu?: boolean; disableHighlight?: boolean; className?: string; }; @@ -356,6 +357,7 @@ const SidebarItemBase = forwardRef((props, ref) => { icon: Icon, text, hasNotifications = false, + hasSubmenu = false, disableHighlight = false, onClick, children, @@ -370,12 +372,12 @@ const SidebarItemBase = forwardRef((props, ref) => { const { isOpen } = useContext(SidebarContext); const divStyle = - !isOpen && children ? { display: 'flex', marginLeft: '24px' } : {}; + !isOpen && hasSubmenu ? { display: 'flex', marginLeft: '24px' } : {}; const displayItemIcon = (
- {!isOpen && children ? : <>} + {!isOpen && hasSubmenu ? : <>}
); @@ -492,6 +494,7 @@ const SidebarItemWithSubmenu = ({ className={classnames(isHoveredOn && classes.highlighted)} >