From c353e23cdd22b5cd89def161f05f93007431da72 Mon Sep 17 00:00:00 2001 From: Nikita Khristinin Date: Tue, 18 Feb 2025 15:50:12 +0100 Subject: [PATCH] Clear gap filters after unmounting component --- .../rules_with_gaps_overview_panel/index.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_gaps/components/rules_with_gaps_overview_panel/index.tsx b/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_gaps/components/rules_with_gaps_overview_panel/index.tsx index 0963fc0836471..fdeb8a3652592 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_gaps/components/rules_with_gaps_overview_panel/index.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_gaps/components/rules_with_gaps_overview_panel/index.tsx @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import { EuiButton, @@ -39,6 +39,16 @@ export const RulesWithGapsOverviewPanel = () => { }); const [isPopoverOpen, setPopover] = useState(false); + useEffect(() => { + return () => { + // reset filter options when unmounting + setFilterOptions({ + gapSearchRange: defaultRangeValue, + showRulesWithGaps: false, + }); + }; + }, [setFilterOptions]); + const rangeValueToLabel = { [GapRangeValue.LAST_24_H]: i18n.RULE_GAPS_OVERVIEW_PANEL_LAST_24_HOURS_LABEL, [GapRangeValue.LAST_3_D]: i18n.RULE_GAPS_OVERVIEW_PANEL_LAST_3_DAYS_LABEL,