Skip to content

Commit 86ca661

Browse files
committed
temporary fix for layout state
1 parent f60e363 commit 86ca661

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/sidebar/NavItem.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { useEffect } from 'react';
22
import {
3+
NavigationType,
34
useLocation,
45
useNavigate,
56
useNavigationType,
6-
NavigationType,
7+
useSearchParams,
78
} from 'react-router-dom';
89
import { useTranslation } from 'react-i18next';
910
import { NavNode } from 'state/types';
@@ -15,8 +16,8 @@ import { clusterState } from 'state/clusterAtom';
1516
import { columnLayoutState } from 'state/columnLayoutAtom';
1617

1718
import {
18-
SideNavigationSubItem,
1919
SideNavigationItem,
20+
SideNavigationSubItem,
2021
} from '@ui5/webcomponents-react';
2122
import { isResourceEditedState } from 'state/resourceEditedAtom';
2223

@@ -35,6 +36,8 @@ export function NavItem({ node, subItem = false }: NavItemProps) {
3536
const urlGenerators = useUrl();
3637
const navigate = useNavigate();
3738
const location = useLocation();
39+
const [searchParams] = useSearchParams();
40+
3841
const navigationType = useNavigationType();
3942
const setLayoutColumn = useSetRecoilState(columnLayoutState);
4043
const [isResourceEdited, setIsResourceEdited] = useRecoilState(
@@ -83,11 +86,17 @@ export function NavItem({ node, subItem = false }: NavItemProps) {
8386
isFormOpen,
8487
setIsFormOpen,
8588
() => {
86-
setLayoutColumn({
87-
midColumn: null,
88-
endColumn: null,
89-
layout: 'OneColumn',
90-
});
89+
// TODO: The layout state change is too late. It happens always after page load.
90+
const layout = searchParams.get('layout');
91+
console.log(layout);
92+
if (!layout) {
93+
setLayoutColumn({
94+
midColumn: null,
95+
endColumn: null,
96+
layout: 'OneColumn',
97+
});
98+
}
99+
91100
const url = node.createUrlFn
92101
? node.createUrlFn(urlGenerators)
93102
: scopedUrl(node.pathSegment);

0 commit comments

Comments
 (0)