Skip to content

Commit

Permalink
[Dashboard] Clear Add Panel On App Leave (#94530) (#94633)
Browse files Browse the repository at this point in the history
* cleared add panel in useEffect cleanup function
  • Loading branch information
ThomThomson authored Mar 15, 2021
1 parent 3ed0a00 commit 2e917c9
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { i18n } from '@kbn/i18n';
import angular from 'angular';
import React, { useCallback, useEffect, useMemo, useState } from 'react';

import UseUnmount from 'react-use/lib/useUnmount';
import { useKibana } from '../../services/kibana_react';
import { IndexPattern, SavedQuery, TimefilterContract } from '../../services/data';
import {
Expand Down Expand Up @@ -114,7 +115,9 @@ export function DashboardTopNav({
id || DASHBOARD_PANELS_UNSAVED_ID
);
}
return () => visibleSubscription.unsubscribe();
return () => {
visibleSubscription.unsubscribe();
};
}, [chrome, allowByValueEmbeddables, dashboardStateManager, savedDashboard]);

const addFromLibrary = useCallback(() => {
Expand Down Expand Up @@ -458,6 +461,10 @@ export function DashboardTopNav({
share,
]);

UseUnmount(() => {
clearAddPanel();
});

const getNavBarProps = () => {
const shouldShowNavBarComponent = (forceShow: boolean): boolean =>
(forceShow || state.chromeIsVisible) && !dashboardStateManager.getFullScreenMode();
Expand Down

0 comments on commit 2e917c9

Please sign in to comment.