[ML] Anomaly Explorer: Prevent crash on anomaly table filter#213075
[ML] Anomaly Explorer: Prevent crash on anomaly table filter#213075rbrtj merged 2 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/ml-ui (:ml) |
| : state; | ||
|
|
||
| const setCallback = useRef<typeof setState>(); | ||
| const setCallback = useRef<typeof setState>(setState); |
There was a problem hiding this comment.
This looks good, preventing the crashes which I have been seeing when changing the filter.
However looks like the URL is persisting the anomalies table page index when changing properties of the view, such as the selected job ID(s). I think we should reset the page index to 0 when changing the selected job(s). @rbrtj @darnautov what do you think? I'd still recommend getting this fix in, and then potentially doing the reset in a follow-up unless it's a simple change.
There was a problem hiding this comment.
It should definitely reset the page index to 0 when changing the selected jobs, in my opinion.
Also, without this fix, the page would crash if we select a page in the anomalies table that is not available for a different job (..and then we change the job).
There was a problem hiding this comment.
As discussed offline, let's fix the page index reset to 0 in a separate PR, and get this fix for the page crash in first.
💚 Build Succeeded
Metrics [docs]Async chunks
Page load bundle
cc @rbrtj |
peteharverson
left a comment
There was a problem hiding this comment.
LGTM. Please create a separate issue for the page reset when the job ID, query or time range changes.
|
Starting backport for target branches: 8.18, 9.0 https://github.com/elastic/kibana/actions/runs/13710136881 |
…#213075) Fix for: elastic#212569 From what I found, the issue was with the `useUrlStateService` after changes introduced in elastic#203224, which made the service more generic. When filtering causes the `explorer` to remount the `AnomaliesTable`, pagination state updates are triggered before the effect that sets `setCallback.current` executes. Initializing the ref with `setState` ensures its availability from the first render. https://github.com/user-attachments/assets/d1aa8409-56e5-4632-a5f2-82350b877db6 (cherry picked from commit 0210468)
…#213075) Fix for: elastic#212569 From what I found, the issue was with the `useUrlStateService` after changes introduced in elastic#203224, which made the service more generic. When filtering causes the `explorer` to remount the `AnomaliesTable`, pagination state updates are triggered before the effect that sets `setCallback.current` executes. Initializing the ref with `setState` ensures its availability from the first render. https://github.com/user-attachments/assets/d1aa8409-56e5-4632-a5f2-82350b877db6 (cherry picked from commit 0210468)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…213075) (#213499) # Backport This will backport the following commits from `main` to `9.0`: - [[ML] Anomaly Explorer: Prevent crash on anomaly table filter (#213075)](#213075) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Robert Jaszczurek","email":"92210485+rbrtj@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-06T23:18:49Z","message":"[ML] Anomaly Explorer: Prevent crash on anomaly table filter (#213075)\n\nFix for: https://github.com/elastic/kibana/issues/212569\nFrom what I found, the issue was with the `useUrlStateService` after\nchanges introduced in https://github.com/elastic/kibana/pull/203224,\nwhich made the service more generic.\n\nWhen filtering causes the `explorer` to remount the `AnomaliesTable`,\npagination state updates are triggered before the effect that sets\n`setCallback.current` executes.\n\nInitializing the ref with `setState` ensures its availability from the\nfirst render.\n\n\nhttps://github.com/user-attachments/assets/d1aa8409-56e5-4632-a5f2-82350b877db6","sha":"0210468548e3d3c68f1ffbeba196ebfe418b0c4e","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix",":ml","Feature:Anomaly Detection","v9.0.0","Team:ML","backport:version","v8.18.0","v9.1.0"],"title":"[ML] Anomaly Explorer: Prevent crash on anomaly table filter","number":213075,"url":"https://github.com/elastic/kibana/pull/213075","mergeCommit":{"message":"[ML] Anomaly Explorer: Prevent crash on anomaly table filter (#213075)\n\nFix for: https://github.com/elastic/kibana/issues/212569\nFrom what I found, the issue was with the `useUrlStateService` after\nchanges introduced in https://github.com/elastic/kibana/pull/203224,\nwhich made the service more generic.\n\nWhen filtering causes the `explorer` to remount the `AnomaliesTable`,\npagination state updates are triggered before the effect that sets\n`setCallback.current` executes.\n\nInitializing the ref with `setState` ensures its availability from the\nfirst render.\n\n\nhttps://github.com/user-attachments/assets/d1aa8409-56e5-4632-a5f2-82350b877db6","sha":"0210468548e3d3c68f1ffbeba196ebfe418b0c4e"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/213075","number":213075,"mergeCommit":{"message":"[ML] Anomaly Explorer: Prevent crash on anomaly table filter (#213075)\n\nFix for: https://github.com/elastic/kibana/issues/212569\nFrom what I found, the issue was with the `useUrlStateService` after\nchanges introduced in https://github.com/elastic/kibana/pull/203224,\nwhich made the service more generic.\n\nWhen filtering causes the `explorer` to remount the `AnomaliesTable`,\npagination state updates are triggered before the effect that sets\n`setCallback.current` executes.\n\nInitializing the ref with `setState` ensures its availability from the\nfirst render.\n\n\nhttps://github.com/user-attachments/assets/d1aa8409-56e5-4632-a5f2-82350b877db6","sha":"0210468548e3d3c68f1ffbeba196ebfe418b0c4e"}}]}] BACKPORT--> Co-authored-by: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com>
…213075) (#213498) # Backport This will backport the following commits from `main` to `8.18`: - [[ML] Anomaly Explorer: Prevent crash on anomaly table filter (#213075)](#213075) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Robert Jaszczurek","email":"92210485+rbrtj@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-06T23:18:49Z","message":"[ML] Anomaly Explorer: Prevent crash on anomaly table filter (#213075)\n\nFix for: https://github.com/elastic/kibana/issues/212569\nFrom what I found, the issue was with the `useUrlStateService` after\nchanges introduced in https://github.com/elastic/kibana/pull/203224,\nwhich made the service more generic.\n\nWhen filtering causes the `explorer` to remount the `AnomaliesTable`,\npagination state updates are triggered before the effect that sets\n`setCallback.current` executes.\n\nInitializing the ref with `setState` ensures its availability from the\nfirst render.\n\n\nhttps://github.com/user-attachments/assets/d1aa8409-56e5-4632-a5f2-82350b877db6","sha":"0210468548e3d3c68f1ffbeba196ebfe418b0c4e","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix",":ml","Feature:Anomaly Detection","v9.0.0","Team:ML","backport:version","v8.18.0","v9.1.0"],"title":"[ML] Anomaly Explorer: Prevent crash on anomaly table filter","number":213075,"url":"https://github.com/elastic/kibana/pull/213075","mergeCommit":{"message":"[ML] Anomaly Explorer: Prevent crash on anomaly table filter (#213075)\n\nFix for: https://github.com/elastic/kibana/issues/212569\nFrom what I found, the issue was with the `useUrlStateService` after\nchanges introduced in https://github.com/elastic/kibana/pull/203224,\nwhich made the service more generic.\n\nWhen filtering causes the `explorer` to remount the `AnomaliesTable`,\npagination state updates are triggered before the effect that sets\n`setCallback.current` executes.\n\nInitializing the ref with `setState` ensures its availability from the\nfirst render.\n\n\nhttps://github.com/user-attachments/assets/d1aa8409-56e5-4632-a5f2-82350b877db6","sha":"0210468548e3d3c68f1ffbeba196ebfe418b0c4e"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/213075","number":213075,"mergeCommit":{"message":"[ML] Anomaly Explorer: Prevent crash on anomaly table filter (#213075)\n\nFix for: https://github.com/elastic/kibana/issues/212569\nFrom what I found, the issue was with the `useUrlStateService` after\nchanges introduced in https://github.com/elastic/kibana/pull/203224,\nwhich made the service more generic.\n\nWhen filtering causes the `explorer` to remount the `AnomaliesTable`,\npagination state updates are triggered before the effect that sets\n`setCallback.current` executes.\n\nInitializing the ref with `setState` ensures its availability from the\nfirst render.\n\n\nhttps://github.com/user-attachments/assets/d1aa8409-56e5-4632-a5f2-82350b877db6","sha":"0210468548e3d3c68f1ffbeba196ebfe418b0c4e"}}]}] BACKPORT--> Co-authored-by: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com>
…#213075) Fix for: elastic#212569 From what I found, the issue was with the `useUrlStateService` after changes introduced in elastic#203224, which made the service more generic. When filtering causes the `explorer` to remount the `AnomaliesTable`, pagination state updates are triggered before the effect that sets `setCallback.current` executes. Initializing the ref with `setState` ensures its availability from the first render. https://github.com/user-attachments/assets/d1aa8409-56e5-4632-a5f2-82350b877db6
Fix for: #212569
From what I found, the issue was with the
useUrlStateServiceafter changes introduced in #203224, which made the service more generic.When filtering causes the
explorerto remount theAnomaliesTable, pagination state updates are triggered before the effect that setssetCallback.currentexecutes.Initializing the ref with
setStateensures its availability from the first render.Screen.Recording.2025-03-04.at.12.36.28.mov