From d202e36001b9639aec9fdcdd29ca4b3b964496c7 Mon Sep 17 00:00:00 2001 From: Khristinin Nikita Date: Fri, 21 Feb 2025 10:22:57 +0100 Subject: [PATCH] Clear gap filters after unmounting component (#211588) ## When we move out monitoring tab we reset filters to show only rule with gaps https://github.com/user-attachments/assets/d86b248e-62e1-41c7-9873-8140a8d86b81 Co-authored-by: Elastic Machine (cherry picked from commit 24d948db43cd55e4a25836ba3d227aaffbd08891) --- .../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,