[Lens] Reload on change via history object (#81753)
This commit is contained in:
parent
677b373ade
commit
d8c37fe890
|
@ -151,6 +151,11 @@ export async function mountApp(
|
||||||
trackUiEvent('loaded_404');
|
trackUiEvent('loaded_404');
|
||||||
return <FormattedMessage id="xpack.lens.app404" defaultMessage="404 Not Found" />;
|
return <FormattedMessage id="xpack.lens.app404" defaultMessage="404 Not Found" />;
|
||||||
}
|
}
|
||||||
|
// 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 = params.history.listen(() => {
|
||||||
|
window.dispatchEvent(new HashChangeEvent('hashchange'));
|
||||||
|
});
|
||||||
|
|
||||||
params.element.classList.add('lnsAppWrapper');
|
params.element.classList.add('lnsAppWrapper');
|
||||||
render(
|
render(
|
||||||
|
@ -171,5 +176,6 @@ export async function mountApp(
|
||||||
return () => {
|
return () => {
|
||||||
instance.unmount();
|
instance.unmount();
|
||||||
unmountComponentAtNode(params.element);
|
unmountComponentAtNode(params.element);
|
||||||
|
unlistenParentHistory();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,6 +154,7 @@ export class EditorFrameService {
|
||||||
initialVisualizationId={
|
initialVisualizationId={
|
||||||
(doc && doc.visualizationType) || firstVisualizationId || null
|
(doc && doc.visualizationType) || firstVisualizationId || null
|
||||||
}
|
}
|
||||||
|
key={doc?.savedObjectId} // ensures rerendering when switching to another visualization inside of lens (eg global search)
|
||||||
core={core}
|
core={core}
|
||||||
plugins={plugins}
|
plugins={plugins}
|
||||||
ExpressionRenderer={plugins.expressions.ReactExpressionRenderer}
|
ExpressionRenderer={plugins.expressions.ReactExpressionRenderer}
|
||||||
|
|
Loading…
Reference in a new issue