[ML] Anomaly Detection: Restore focus to row actions menu in job management table#230170
[ML] Anomaly Detection: Restore focus to row actions menu in job management table#230170rbrtj merged 5 commits intoelastic:mainfrom
Conversation
| ); | ||
|
|
||
| return ( | ||
| <EuiPortal> |
There was a problem hiding this comment.
This was obsolete, EuiFlyout already comes with a Portal
|
Pinging @elastic/ml-ui (:ml) |
jgowdyelastic
left a comment
There was a problem hiding this comment.
Left a couple of comments, but on the whole LGTM
| end: number; | ||
| onClose: () => void; | ||
| onModelSnapshotAnnotationClick?: (modelSnapshot: ModelSnapshot) => void; | ||
| focusTrapProps?: EuiFlyoutProps['focusTrapProps']; |
There was a problem hiding this comment.
As we're using this type a lot, maybe it's worth exporting it from create_focus_trap_props.ts
e.g.
export type FocusTrapProps = EuiFlyoutResizableProps['focusTrapProps'];
| }; | ||
|
|
||
| export const createJobActionFocusRestoration = (jobId: string) => { | ||
| const actionButton = document.getElementById(`${jobId}-actions`)?.querySelector('button'); |
There was a problem hiding this comment.
nit, I think this could be:
| const actionButton = document.getElementById(`${jobId}-actions`)?.querySelector('button'); | |
| const actionButton = document.querySelector(`#${jobId}-actions button`); |
There was a problem hiding this comment.
It seems that actionButton would be typed as Element, which is a base class for e.g., HTMLElement, and doesn't have the focus method typed. I think it's better to stick with the current implementation rather than asserting the type or adding a type guard
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
History
cc @rbrtj |
|
Starting backport for target branches: 8.17, 8.18, 8.19, 9.0 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
…0170) Fix for: elastic#195017 This PR fixes an issue with focus restoration, where opening a Flyout or Modal from the context action menu doesn't properly restore focus. Unfortunately, this isn't fixable on the Eui side at the moment, so to address this, we need to manually restore focus to the action button. It creates reusable helpers responsible for creating `focusTrapProps` for flyouts and manually restoring focus for Modals, as this issue occurs whenever a Flyout or Modal is triggered from the context action menu. After fix: https://github.com/user-attachments/assets/19c259e0-1c8b-4304-bcdd-918d4e0d45cf
|
Starting backport for target branches: 9.1 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…0170) Fix for: elastic#195017 This PR fixes an issue with focus restoration, where opening a Flyout or Modal from the context action menu doesn't properly restore focus. Unfortunately, this isn't fixable on the Eui side at the moment, so to address this, we need to manually restore focus to the action button. It creates reusable helpers responsible for creating `focusTrapProps` for flyouts and manually restoring focus for Modals, as this issue occurs whenever a Flyout or Modal is triggered from the context action menu. After fix: https://github.com/user-attachments/assets/19c259e0-1c8b-4304-bcdd-918d4e0d45cf (cherry picked from commit 742ddef) # Conflicts: # src/platform/packages/shared/response-ops/rule_form/flyout/rule_form_flyout.tsx
) (#230735) # Backport This will backport the following commits from `main` to `9.1`: - [[ML] Anomaly Detection: Restore focus to row actions menu (#230170)](#230170) <!--- Backport version: 10.0.1 --> ### 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-08-05T10:55:36Z","message":"[ML] Anomaly Detection: Restore focus to row actions menu (#230170)\n\nFix for: https://github.com/elastic/kibana/issues/195017\nThis PR fixes an issue with focus restoration, where opening a Flyout or\nModal from the context action menu doesn't properly restore focus.\nUnfortunately, this isn't fixable on the Eui side at the moment, so to\naddress this, we need to manually restore focus to the action button. It\ncreates reusable helpers responsible for creating `focusTrapProps` for\nflyouts and manually restoring focus for Modals, as this issue occurs\nwhenever a Flyout or Modal is triggered from the context action menu.\nAfter fix:\n\n\n\n\n\n\nhttps://github.com/user-attachments/assets/19c259e0-1c8b-4304-bcdd-918d4e0d45cf","sha":"742ddef446a90668868a566b2eef5916552425e8","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":[":ml","release_note:skip","Team:ML","backport:prev-minor","v9.2.0"],"title":"[ML] Anomaly Detection: Restore focus to row actions menu","number":230170,"url":"https://github.com/elastic/kibana/pull/230170","mergeCommit":{"message":"[ML] Anomaly Detection: Restore focus to row actions menu (#230170)\n\nFix for: https://github.com/elastic/kibana/issues/195017\nThis PR fixes an issue with focus restoration, where opening a Flyout or\nModal from the context action menu doesn't properly restore focus.\nUnfortunately, this isn't fixable on the Eui side at the moment, so to\naddress this, we need to manually restore focus to the action button. It\ncreates reusable helpers responsible for creating `focusTrapProps` for\nflyouts and manually restoring focus for Modals, as this issue occurs\nwhenever a Flyout or Modal is triggered from the context action menu.\nAfter fix:\n\n\n\n\n\n\nhttps://github.com/user-attachments/assets/19c259e0-1c8b-4304-bcdd-918d4e0d45cf","sha":"742ddef446a90668868a566b2eef5916552425e8"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/230170","number":230170,"mergeCommit":{"message":"[ML] Anomaly Detection: Restore focus to row actions menu (#230170)\n\nFix for: https://github.com/elastic/kibana/issues/195017\nThis PR fixes an issue with focus restoration, where opening a Flyout or\nModal from the context action menu doesn't properly restore focus.\nUnfortunately, this isn't fixable on the Eui side at the moment, so to\naddress this, we need to manually restore focus to the action button. It\ncreates reusable helpers responsible for creating `focusTrapProps` for\nflyouts and manually restoring focus for Modals, as this issue occurs\nwhenever a Flyout or Modal is triggered from the context action menu.\nAfter fix:\n\n\n\n\n\n\nhttps://github.com/user-attachments/assets/19c259e0-1c8b-4304-bcdd-918d4e0d45cf","sha":"742ddef446a90668868a566b2eef5916552425e8"}}]}] BACKPORT-->
…0170) Fix for: elastic#195017 This PR fixes an issue with focus restoration, where opening a Flyout or Modal from the context action menu doesn't properly restore focus. Unfortunately, this isn't fixable on the Eui side at the moment, so to address this, we need to manually restore focus to the action button. It creates reusable helpers responsible for creating `focusTrapProps` for flyouts and manually restoring focus for Modals, as this issue occurs whenever a Flyout or Modal is triggered from the context action menu. After fix: https://github.com/user-attachments/assets/19c259e0-1c8b-4304-bcdd-918d4e0d45cf
|
Pinging @elastic/kibana-accessibility (Project:Accessibility) |

Fix for: #195017
This PR fixes an issue with focus restoration, where opening a Flyout or Modal from the context action menu doesn't properly restore focus. Unfortunately, this isn't fixable on the Eui side at the moment, so to address this, we need to manually restore focus to the action button. It creates reusable helpers responsible for creating
focusTrapPropsfor flyouts and manually restoring focus for Modals, as this issue occurs whenever a Flyout or Modal is triggered from the context action menu.After fix:
Screen.Recording.2025-08-01.at.10.33.49.mov