From 016ed01db54b9966c89246c745c514b2bc1fd8b3 Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada <117196660+saimedhi@users.noreply.github.com> Date: Tue, 27 Aug 2024 08:55:25 -0700 Subject: [PATCH] Fix Side Nav URL behavior with NewHomePage enabled (#312) Signed-off-by: saimedhi (cherry picked from commit c8faaf70233255c678f29d78c7f9f3f0b7aad0ab) --- public/render_app.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/public/render_app.tsx b/public/render_app.tsx index c642c6bc..75a9ad32 100644 --- a/public/render_app.tsx +++ b/public/render_app.tsx @@ -38,5 +38,20 @@ export const renderApp = ( params.element ); - return () => ReactDOM.unmountComponentAtNode(params.element); + const expectedBasePath = '/app/flow-framework#'; + + const unlistenParentHistory = params.history.listen(() => { + if ( + hideInAppSideNavBar && + window.location.pathname.endsWith('/app/flow-framework') + ) { + window.location.href = `${expectedBasePath}`; + window.dispatchEvent(new HashChangeEvent('hashchange')); + } + }); + + return () => { + ReactDOM.unmountComponentAtNode(params.element); + unlistenParentHistory(); + }; };