Skip to content

Commit

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

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

* Adding space back in
simianhacker authored Jun 24, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent d5f68ee commit b12095b
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
@@ -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,

0 comments on commit b12095b

Please sign in to comment.