-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SecuritySolution] Close field editor when page context is lost #124378
Conversation
Pinging @elastic/security-threat-hunting (Team:Threat Hunting) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks great. I just noticed one edge case. Because timeline only closed the field editor when show
value changes. It doesn't close the editor when you navigate to a security solutions page that doesn't have a timeline (Endpoint page).
...ns/security_solution/public/timelines/components/timeline/body/column_headers/index.test.tsx
Outdated
Show resolved
Hide resolved
Hi @machadoum , very good catches! I addressed your suggestions and I improved the tests a little bit more. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -137,6 +142,10 @@ const StatefulEventsViewerComponent: React.FC<Props> = ({ | |||
} | |||
return () => { | |||
deleteEventQuery({ id, inputId: 'global' }); | |||
if (editorActionsRef.current) { | |||
// eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need this here? i thought just above the dependency array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, It is needed here too, this error pops if not diabled:
The ref value 'fieldEditorActionsRef.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy 'fieldEditorActionsRef.current' to a variable inside the effect, and use that variable in the cleanup function
sortDirection: Direction.desc, | ||
}, | ||
]; | ||
const defaultProps: ColumnHeadersComponentProps = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for cleaning this up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a question about that type exception. tested locally and LGTM. thanks @semd !
💚 Build SucceededMetrics [docs]Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @semd |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
…tic#124378) * close field editor when context is lost * tests added * typecheck clean * close editor when timeline is unmounted (cherry picked from commit 21710df)
…tic#124378) * close field editor when context is lost * tests added * typecheck clean * close editor when timeline is unmounted (cherry picked from commit 21710df) # Conflicts: # x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.tsx
Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync. |
1 similar comment
Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync. |
Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync. |
…#124378) (#124935) * [SecuritySolution] Close field editor when page context is lost (#124378) * close field editor when context is lost * tests added * typecheck clean * close editor when timeline is unmounted (cherry picked from commit 21710df) # Conflicts: # x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.tsx * fix test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
issue: #123209
Implemented the close action on the field editor, by leveraging the returned function from the
dataViewFieldEditor.openEditor
function call.The reference is needed here because the button that triggers the field editor flyout is unmounted when it is clicked. The
closeEditor
action needs to be triggered when the original component that opened the "fieldBrowser" in the first place is unmounted (alerts tables) or it is hidden (timeline):close_field_editor_flyout_fix.mov
Checklist