Skip to content

Commit

Permalink
[Metrics UI] Prevent saved views from trampling URL state (#103146) (#…
Browse files Browse the repository at this point in the history
…103367)

* [Metrics UI] Prevent saved views from trampling URL state

* Adding space back in
  • Loading branch information
simianhacker authored Jun 24, 2021
1 parent 78a030d commit 00c2047
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions x-pack/plugins/infra/public/containers/saved_view/saved_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,21 @@ export const useSavedView = (props: Props) => {
}, [urlState, setUrlState, currentView, defaultViewId, data]);

useEffect(() => {
if (!currentView && !loading && data) {
if (!currentView && !loading && data && shouldLoadDefault) {
const viewToSet = views.find((v) => v.id === urlState.viewId);
if (viewToSet) setCurrentView(viewToSet);
else loadDefaultViewIfSet();
}
}, [loading, currentView, data, views, setCurrentView, loadDefaultViewIfSet, urlState.viewId]);
}, [
loading,
currentView,
data,
views,
setCurrentView,
loadDefaultViewIfSet,
urlState.viewId,
shouldLoadDefault,
]);

return {
views,
Expand Down

0 comments on commit 00c2047

Please sign in to comment.