From d11b4561d86f7f720f0ab075f1b118c0395720b9 Mon Sep 17 00:00:00 2001 From: Maxim Palenov Date: Mon, 18 Nov 2024 14:34:12 +0100 Subject: [PATCH] prevent dispatching unchanged EQL Options --- .../timeline/query_bar/eql/index.tsx | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/eql/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/eql/index.tsx index 9bf3e4cb9fd20..51e2dd2d368d6 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/eql/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_bar/eql/index.tsx @@ -85,27 +85,31 @@ export const EqlQueryBarTimeline = memo(({ timelineId }: { timelineId: string }) return; } - dispatch( - timelineActions.updateEqlOptions({ - id: timelineId, - field: 'query', - value: `${formData.eqlQueryBar.query.query}`, - }) - ); - - for (const fieldName of Object.keys(formData.eqlOptions) as Array< - keyof typeof formData.eqlOptions - >) { + if (eqlOptions.query !== `${formData.eqlQueryBar.query.query}`) { dispatch( timelineActions.updateEqlOptions({ id: timelineId, - field: fieldName, - value: formData.eqlOptions[fieldName], + field: 'query', + value: `${formData.eqlQueryBar.query.query}`, }) ); } + + for (const fieldName of Object.keys(formData.eqlOptions) as Array< + keyof typeof formData.eqlOptions + >) { + if (formData.eqlOptions[fieldName] !== eqlOptions[fieldName]) { + dispatch( + timelineActions.updateEqlOptions({ + id: timelineId, + field: fieldName, + value: formData.eqlOptions[fieldName], + }) + ); + } + } }, - [dispatch, timelineId] + [dispatch, timelineId, eqlOptions] ); const { form } = useForm({