[Stack Monitoring] Fix hashchange detection on sidenav link (#114727)

This commit is contained in:
Zacqary Adam Xeper 2021-10-13 10:36:07 -05:00 committed by GitHub
parent fdc0ce749a
commit da8264f26a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,9 +59,15 @@ import { LogStashNodePipelinesPage } from './pages/logstash/node_pipelines';
export const renderApp = (
core: CoreStart,
plugins: MonitoringStartPluginDependencies,
{ element, setHeaderActionMenu }: AppMountParameters,
{ element, history, setHeaderActionMenu }: AppMountParameters,
externalConfig: ExternalConfig
) => {
// 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 unlistenParentHistory = history.listen(() => {
window.dispatchEvent(new HashChangeEvent('hashchange'));
});
ReactDOM.render(
<MonitoringApp
core={core}
@ -74,6 +80,7 @@ export const renderApp = (
return () => {
ReactDOM.unmountComponentAtNode(element);
unlistenParentHistory();
};
};