11import { useEffect } from 'react' ;
22import {
3+ NavigationType ,
34 useLocation ,
45 useNavigate ,
56 useNavigationType ,
6- NavigationType ,
7+ useSearchParams ,
78} from 'react-router-dom' ;
89import { useTranslation } from 'react-i18next' ;
910import { NavNode } from 'state/types' ;
@@ -15,8 +16,8 @@ import { clusterState } from 'state/clusterAtom';
1516import { columnLayoutState } from 'state/columnLayoutAtom' ;
1617
1718import {
18- SideNavigationSubItem ,
1919 SideNavigationItem ,
20+ SideNavigationSubItem ,
2021} from '@ui5/webcomponents-react' ;
2122import { 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