diff --git a/src/components/LeftDrawer/LeftDrawer.spec.tsx b/src/components/LeftDrawer/LeftDrawer.spec.tsx
index dc22717e3d..a0aaf9336c 100644
--- a/src/components/LeftDrawer/LeftDrawer.spec.tsx
+++ b/src/components/LeftDrawer/LeftDrawer.spec.tsx
@@ -220,4 +220,40 @@ describe('Testing Left Drawer component for ADMIN', () => {
expect(global.window.location.pathname).toContain('/orglist');
});
+
+ it('Should set hideDrawer to false when initially null', async () => {
+ const mockSetHideDrawer = vi.fn();
+ await act(async () => {
+ render(
+
+
+
+
+
+
+ ,
+ );
+ });
+ expect(mockSetHideDrawer).toHaveBeenCalledWith(false);
+ expect(mockSetHideDrawer).toHaveBeenCalledTimes(1);
+ });
+
+ it('Should not call setHideDrawer when hideDrawer has a value', async () => {
+ const mockSetHideDrawer = vi.fn();
+ await act(async () => {
+ render(
+
+
+
+
+
+
+ ,
+ );
+ });
+ expect(mockSetHideDrawer).not.toHaveBeenCalled();
+ });
});
diff --git a/src/components/LeftDrawerOrg/LeftDrawerOrg.spec.tsx b/src/components/LeftDrawerOrg/LeftDrawerOrg.spec.tsx
index 3fa6c0205e..f0e5d446d1 100644
--- a/src/components/LeftDrawerOrg/LeftDrawerOrg.spec.tsx
+++ b/src/components/LeftDrawerOrg/LeftDrawerOrg.spec.tsx
@@ -472,4 +472,47 @@ describe('Testing LeftDrawerOrg component for SUPERADMIN', () => {
,
);
});
+
+ test('Should set hideDrawer to false when initially null', async () => {
+ const mockSetHideDrawer = vi.fn();
+ render(
+
+
+
+
+
+
+
+
+ ,
+ );
+ await wait();
+ expect(mockSetHideDrawer).toHaveBeenCalledWith(false);
+ expect(mockSetHideDrawer).toHaveBeenCalledTimes(1);
+ });
+
+ test('Should not call setHideDrawer when hideDrawer has a value', async () => {
+ const mockSetHideDrawer = vi.fn();
+ render(
+
+
+
+
+
+
+
+
+ ,
+ );
+ await wait();
+ expect(mockSetHideDrawer).not.toHaveBeenCalled();
+ });
});
diff --git a/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx b/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx
index 35173a930e..de9583843c 100644
--- a/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx
+++ b/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx
@@ -74,6 +74,13 @@ const leftDrawerOrg = ({
() => getIdFromPath(location.pathname),
[location.pathname],
);
+
+ useEffect(() => {
+ if (hideDrawer === null) {
+ setHideDrawer(false);
+ }
+ }, []);
+
// Check if the current page is admin profile page
useEffect(() => {