diff --git a/x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx b/x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx index b6557154a1302..b0f3ccb8c21ad 100644 --- a/x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx @@ -110,15 +110,17 @@ const InvestigateInTimelineActionComponent = (alertIds: string[]) => { }; export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) => { - const [caseTitle, setCaseTitle] = useState(null); + const [spyState, setSpyState] = useState<{ caseTitle: string | undefined }>({ + caseTitle: undefined, + }); const onCaseDataSuccess = useCallback( (data: Case) => { - if (!caseTitle || caseTitle !== data.title) { - setCaseTitle(data.title); + if (spyState.caseTitle === undefined) { + setSpyState({ caseTitle: data.title }); } }, - [caseTitle] + [spyState.caseTitle] ); const { @@ -200,7 +202,6 @@ export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) = }) ); }, [dispatch]); - return ( <> {casesUi.getCaseView({ @@ -247,7 +248,7 @@ export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) = useFetchAlertData, userCanCrud, })} - {caseTitle && } + ); }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/flyout/add_to_case_button/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/flyout/add_to_case_button/index.tsx index 7fa2ec07b0ea2..a4c6fe1e344b3 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/flyout/add_to_case_button/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/flyout/add_to_case_button/index.tsx @@ -88,12 +88,9 @@ const AddToCaseButtonComponent: React.FC = ({ timelineId }) => { const handleNewCaseClick = useCallback(() => { handlePopoverClose(); - - dispatch(showTimeline({ id: TimelineId.active, show: false })); - navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { path: getCreateCaseUrl(), - }).then(() => + }).then(() => { dispatch( setInsertTimeline({ graphEventId, @@ -101,8 +98,9 @@ const AddToCaseButtonComponent: React.FC = ({ timelineId }) => { timelineSavedObjectId: savedObjectId, timelineTitle: timelineTitle.length > 0 ? timelineTitle : i18n.UNTITLED_TIMELINE, }) - ) - ); + ); + dispatch(showTimeline({ id: TimelineId.active, show: false })); + }); }, [ dispatch, graphEventId,