fix(sidebarItem): only add arrow icon to items with a submenu

Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
Phil Kuang
2022-05-19 17:00:50 -04:00
parent f1707219b2
commit 65840b17be
2 changed files with 10 additions and 2 deletions
+5
View File
@@ -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
@@ -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<any, SidebarItemProps>((props, ref) => {
icon: Icon,
text,
hasNotifications = false,
hasSubmenu = false,
disableHighlight = false,
onClick,
children,
@@ -370,12 +372,12 @@ const SidebarItemBase = forwardRef<any, SidebarItemProps>((props, ref) => {
const { isOpen } = useContext(SidebarContext);
const divStyle =
!isOpen && children ? { display: 'flex', marginLeft: '24px' } : {};
!isOpen && hasSubmenu ? { display: 'flex', marginLeft: '24px' } : {};
const displayItemIcon = (
<div style={divStyle}>
<Icon fontSize="small" />
{!isOpen && children ? <ArrowRightIcon /> : <></>}
{!isOpen && hasSubmenu ? <ArrowRightIcon /> : <></>}
</div>
);
@@ -492,6 +494,7 @@ const SidebarItemWithSubmenu = ({
className={classnames(isHoveredOn && classes.highlighted)}
>
<SidebarItemBase
hasSubmenu
className={isActive ? classes.selected : ''}
{...props}
>