Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where defaultAppId redirect could fire outside home app #76415

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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