Skip to content

Commit 55e2929

Browse files
author
Gianmarco Manni
committed
x
1 parent 4924335 commit 55e2929

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

rollup.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ const plugins = [
2121
}),
2222
nodeResolve(),
2323
terser({
24-
output: { comments: false },
24+
output: { comments: true },
2525
compress: {
26-
drop_console: true,
26+
drop_console: false,
2727
},
2828
}),
2929
];

src/lib/Layout/PanelSideBarLayout/PanelSideBar/Context/PanelSideBarContext.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Context, createContext, useCallback, useContext, useEffect, useState } from "react";
1+
import React, { Context, createContext, useCallback, useContext, useState } from "react";
22
import { getActivePanel } from "../Utils/getActivePanel";
33
import { PanelSideBarContextProps } from "./PanelSideBarContextProps";
44

@@ -22,8 +22,10 @@ export interface PanelSideBarMenuProviderProps<TPanelItemId extends string, TPan
2222
export const PanelSideBarProvider = <TPanelItemId extends string, TPanelItem>(
2323
props: PanelSideBarMenuProviderProps<TPanelItemId, TPanelItem>,
2424
) => {
25-
const { children, defaultActivePanelId, sidebarOpenByDefault = true } = props;
26-
const [menuItems, setMenuItems] = useState(props.menuItems);
25+
const { children, defaultActivePanelId, sidebarOpenByDefault = true, menuItems: defaultMenuItems } = props;
26+
console.log(defaultMenuItems);
27+
const [menuItems, setMenuItems] = useState(defaultMenuItems);
28+
console.log(menuItems);
2729
const [isSidebarOpen, setIsSidebarOpen] = useState(sidebarOpenByDefault);
2830
const toggleSidebar = () => setIsSidebarOpen((prev) => !prev);
2931

@@ -53,8 +55,6 @@ export const PanelSideBarProvider = <TPanelItemId extends string, TPanelItem>(
5355
}
5456
}, []);
5557

56-
useEffect(() => recomputeActivePanel(), [menuItems]);
57-
5858
return (
5959
<PanelSideBarContext.Provider
6060
value={{

src/lib/Layout/PanelSideBarLayout/PanelSideBar/PanelSidebar.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ export const PanelSideBar = <TPanelItemId extends string, TPanelItem>(props: Pan
1919
>();
2020

2121
if (renderFirstItemsLevelAsTiles) {
22-
if (menuItems.find((x) => !x.icon)) {
22+
console.log(menuItems);
23+
if (menuItems?.find((x) => !x.icon)) {
2324
throw new Error("Outer panel icon is required");
2425
}
2526

26-
const activePanel: PanelItem<TPanelItemId, TPanelItem> | undefined = menuItems.find((x) => x.id === activePanelId);
27+
const activePanel: PanelItem<TPanelItemId, TPanelItem> | undefined = menuItems?.find((x) => x.id === activePanelId);
2728
const ButtonIcon = (props: { item: PanelItem<TPanelItemId, TPanelItem> }) => {
2829
const {
2930
item: { disabled, icon, onClick, id, title },
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { PanelItem } from "../Definitions/PanelItem";
22

33
export const getActivePanel = <TPanelItemId extends string, TPanelItem>(items: PanelItem<TPanelItemId, TPanelItem>[], defaultActivePanelId?: TPanelItemId) => {
4-
const activePanel = items.find((x) =>
4+
console.log(items);
5+
const activePanel = items?.find((x) =>
56
x.children ? x.children.find((y) => (y.children ? y.children.find((s) => s.active) : y.active)) : x.active,
67
);
78

8-
return activePanel ?? items.find((x) => (defaultActivePanelId ? x.id === defaultActivePanelId : x.id));
9+
return activePanel ?? items?.find((x) => (defaultActivePanelId ? x.id === defaultActivePanelId : x.id));
910
};

0 commit comments

Comments
 (0)