-
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
[Security Sollution][Alerts] fixes rule preview issue for new terms field #145707
Merged
vitaliidm
merged 8 commits into
elastic:main
from
vitaliidm:alerts/preview-new-terms-issue
Nov 28, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5b2a6d4
[Security Sollution][Alerts] fixes rule preview issue for new terms f…
vitaliidm 79269dd
Merge branch 'main' into alerts/preview-new-terms-issue
vitaliidm 712635b
use validate only
vitaliidm d900adf
Merge branch 'alerts/preview-new-terms-issue' of https://github.com/v…
vitaliidm c26ce90
wrapping in setTimeout
vitaliidm 790bf9e
Merge branch 'main' into alerts/preview-new-terms-issue
vitaliidm be05935
Merge branch 'main' into alerts/preview-new-terms-issue
vitaliidm c7c2a59
Merge branch 'main' into alerts/preview-new-terms-issue
vitaliidm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 fix looks dirty but fine if it's temporary.
I just wanted to share my thoughts. Usually a necessity of
setTimeout()
usage says about design flaws and over-complication. In this case it looks possible to get rid of the problem by rethinking the approach to the data handling. For example I can seeformHooks
is used as a global variable and the value is reused the level up.The cause of the problem is double validation which actually shouldn't happen.
I'm curious if an approach to redesign the components to handle validation in another way was considered as well.
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.
I would recommend to read this section before writing comments like this.
What do you mean by 'double validation'?
I would expect once data in form is changed and available in onChange callback, it can be checked whether it's valid or not. But if you look into standalone example, it's not a case: data is changed, but its validity can not be established.
I would like to see forms-lib assessment of library behaviour before committing to any refactoring.
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.
Thank you for the explanation and pointing to the guidelines.
I didn't mean to offend but rather say that
setTimeout
usually is a red flag which signals there is something wrong.You are right the problem in the the forms-lib. Though it's strange the popular scenario of accessing the validity state in the
onChange
callback wasn't covered already.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, I also commented that it's a workaround and put together ticket and links to it
In this standalone example , it can be seen that in onChange, accessed validity is not correct. Very simple case, but the result is rather unexpected. Let's see what forms-lib will say on that.
I would expect if I get any data from callback: to either access validation status straight away or through running
validate
method. We did the latter in form(though through calling asubmit
before this change) and relied on its results. Which, as it turns out, are not correct in some cases.