Merge pull request #23301 from carnageX/master

feat: Add option for SidebarSubmenuItem to have sub menus expanded by default
This commit is contained in:
Vincenzo Scamporlino
2024-04-23 15:59:18 +02:00
committed by GitHub
3 changed files with 10 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/core-components': patch
---
Added optional `initialShowDropDown` prop to `SidebarSubmenuItem` to internally manage the initial display state of the dropdown items.
+1
View File
@@ -1128,6 +1128,7 @@ export type SidebarSubmenuItemProps = {
icon?: IconComponent;
dropdownItems?: SidebarSubmenuItemDropdownItem[];
exact?: boolean;
initialShowDropdown?: boolean;
};
// @public
@@ -131,6 +131,7 @@ export type SidebarSubmenuItemProps = {
icon?: IconComponent;
dropdownItems?: SidebarSubmenuItemDropdownItem[];
exact?: boolean;
initialShowDropdown?: boolean;
};
/**
@@ -149,7 +150,9 @@ export const SidebarSubmenuItem = (props: SidebarSubmenuItemProps) => {
const currentLocation = useLocation();
let isActive = isLocationMatch(currentLocation, toLocation, exact);
const [showDropDown, setShowDropDown] = useState(false);
const [showDropDown, setShowDropDown] = useState(
props.initialShowDropdown ?? false,
);
const handleClickDropdown = () => {
setShowDropDown(!showDropDown);
};