Skip to content

Commit

Permalink
Fix issue where defaultAppId redirect could fire outside home app (el…
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Sep 2, 2020
1 parent d0f441e commit 6df3481
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/plugins/home/public/application/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,20 @@ export const renderApp = async (

chrome.setBreadcrumbs([{ text: homeTitle }]);

// dispatch synthetic hash change event to update hash history objects
// this is necessary because hash updates triggered by using popState won't trigger this event naturally.
// This must be called before the app is mounted to avoid call this after the redirect to default app logic kicks in
const unlisten = history.listen((location) => {
window.dispatchEvent(new HashChangeEvent('hashchange'));
});

render(
<KibanaContextProvider services={{ ...coreStart }}>
<HomeApp directories={directories} solutions={solutions} />
</KibanaContextProvider>,
element
);

// dispatch synthetic hash change event to update hash history objects
// this is necessary because hash updates triggered by using popState won't trigger this event naturally.
const unlisten = history.listen(() => {
window.dispatchEvent(new HashChangeEvent('hashchange'));
});

return () => {
unmountComponentAtNode(element);
unlisten();
Expand Down

0 comments on commit 6df3481

Please sign in to comment.