From 565c7219ee67feacb3cc96edf6750d2f982a8ac5 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 08:55:55 -0700 Subject: [PATCH] Fix Side Nav URL behavior with NewHomePage enabled (#312) (#315) Signed-off-by: saimedhi (cherry picked from commit c8faaf70233255c678f29d78c7f9f3f0b7aad0ab) Co-authored-by: Sai Medhini Reddy Maryada <117196660+saimedhi@users.noreply.github.com> --- 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(); + }; };