Skip to content

Commit 373beb6

Browse files
[9.3] [Security Solution] fix missing dateRangeField logic in useTimelineEventsHandler (#256351) (#256973)
# Backport This will backport the following commits from `main` to `9.3`: - [[Security Solution] fix missing dateRangeField logic in useTimelineEventsHandler (#256351)](#256351) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Philippe Oberti","email":"philippe.oberti@elastic.co"},"sourceCommit":{"committedDate":"2026-03-10T18:22:29Z","message":"[Security Solution] fix missing dateRangeField logic in useTimelineEventsHandler (#256351)\n\n## Summary\n\nWhile backporting this recently merged\n[PR](#251827) to `8.19`, the CI\nkept failing on the `should load more records according to sample size\ncorrectly` unit test in\n`x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/tabs/query/index.test.tsx`.\n\nThe issue was a missing piece of code in the `useTimelineEventsHandler`.\nThis PR fixes that. I ran the tests locally on the `8.19` branch with\nthis fix and they all passed.\n\nMore explanation on the issue:\n_The test was failing because when we load `loadNextBatch()` (which set\n`activeBatch` to `1`), the effect reruns, compares search params, sees\nthem as different (because `dateRangeField` existed only in\n`prevSearchParameters`), and resets `newActiveBatch` to `0`._\n\n> [!NOTE]\n> This was not found on `main` because the whole test file was\nskipped... This PR does not re-enable the test file because further\nrefactor is needed to make the test pass. Also the speed of the test\nneeds to be lowered (see [this\nticket](https://github.com/elastic/kibana/issues/224186))","sha":"2c40e8ad7403c9c808806a8e0cbf969e5a3801fc","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Threat Hunting:Investigations","backport:all-open","v9.4.0"],"title":"[Security Solution] fix missing dateRangeField logic in useTimelineEventsHandler","number":256351,"url":"https://github.com/elastic/kibana/pull/256351","mergeCommit":{"message":"[Security Solution] fix missing dateRangeField logic in useTimelineEventsHandler (#256351)\n\n## Summary\n\nWhile backporting this recently merged\n[PR](#251827) to `8.19`, the CI\nkept failing on the `should load more records according to sample size\ncorrectly` unit test in\n`x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/tabs/query/index.test.tsx`.\n\nThe issue was a missing piece of code in the `useTimelineEventsHandler`.\nThis PR fixes that. I ran the tests locally on the `8.19` branch with\nthis fix and they all passed.\n\nMore explanation on the issue:\n_The test was failing because when we load `loadNextBatch()` (which set\n`activeBatch` to `1`), the effect reruns, compares search params, sees\nthem as different (because `dateRangeField` existed only in\n`prevSearchParameters`), and resets `newActiveBatch` to `0`._\n\n> [!NOTE]\n> This was not found on `main` because the whole test file was\nskipped... This PR does not re-enable the test file because further\nrefactor is needed to make the test pass. Also the speed of the test\nneeds to be lowered (see [this\nticket](https://github.com/elastic/kibana/issues/224186))","sha":"2c40e8ad7403c9c808806a8e0cbf969e5a3801fc"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/256351","number":256351,"mergeCommit":{"message":"[Security Solution] fix missing dateRangeField logic in useTimelineEventsHandler (#256351)\n\n## Summary\n\nWhile backporting this recently merged\n[PR](#251827) to `8.19`, the CI\nkept failing on the `should load more records according to sample size\ncorrectly` unit test in\n`x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/tabs/query/index.test.tsx`.\n\nThe issue was a missing piece of code in the `useTimelineEventsHandler`.\nThis PR fixes that. I ran the tests locally on the `8.19` branch with\nthis fix and they all passed.\n\nMore explanation on the issue:\n_The test was failing because when we load `loadNextBatch()` (which set\n`activeBatch` to `1`), the effect reruns, compares search params, sees\nthem as different (because `dateRangeField` existed only in\n`prevSearchParameters`), and resets `newActiveBatch` to `0`._\n\n> [!NOTE]\n> This was not found on `main` because the whole test file was\nskipped... This PR does not re-enable the test file because further\nrefactor is needed to make the test pass. Also the speed of the test\nneeds to be lowered (see [this\nticket](https://github.com/elastic/kibana/issues/224186))","sha":"2c40e8ad7403c9c808806a8e0cbf969e5a3801fc"}}]}] BACKPORT--> Co-authored-by: Philippe Oberti <philippe.oberti@elastic.co>
1 parent 98ce4b2 commit 373beb6

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

  • x-pack/solutions/security/plugins/security_solution/public/timelines/containers

x-pack/solutions/security/plugins/security_solution/public/timelines/containers/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ export const useTimelineEventsHandler = ({
411411
runtimeMappings: runtimeMappings ?? {},
412412
...timerange,
413413
...deStructureEqlOptions(eqlOptions),
414+
...(dateRangeField ? { dateRangeField } : {}),
414415
};
415416

416417
const areSearchParamsSame = deepEqual(prevSearchParameters, currentSearchParameters);

0 commit comments

Comments
 (0)