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
Fix validation for entry fields in exception form #151654
Conversation
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
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! I think opening a kibana issue with the comments you added here to the fix would be great too. Thanks for the fix.
// Looks like selectedField return new object every time when we for example add "and" entry | ||
// that's why we need to check for name and type here | ||
// Probably we should use some kind of memoization on parent components for entries | ||
}, [selectedField?.name, selectedField?.type, selectedValue, handleSpacesWarning, onError]); |
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.
These comments are really insightful thanks for finding the root cause of this. Would it be possible for you to add these comments to an issue? This way we can try to add it to the next release to-do list?
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.
Sure, will create an issue. This comment fixes one of the reasons of the validation problem, but main cause it's how we stored our errors before
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.
Here the issue: #151735
## Change validation logic for entry exception field. Close: [elastic#143051 Previously we didn't keep a validation state per field which caused a reset of validation if we still had invalid fields. Or we can have an invalid state for the form, but we removed the invalid field. You can see the videos on the ticket above. ## Solution: Keep validation state per field, like: ```js { [entry.id]: true, } ``` This state can keep old fields, which already were removed, this is why we use the selector to get the actual amount of errors. https://user-images.githubusercontent.com/7609147/220337447-95c1558c-aa85-43d1-87e8-76370aeaf141.mov --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit d93eaa0)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…51732) # Backport This will backport the following commits from `main` to `8.7`: - [Fix validation for entry fields in exception form (#151654)](#151654) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Khristinin Nikita","email":"nikita.khristinin@elastic.co"},"sourceCommit":{"committedDate":"2023-02-21T15:59:54Z","message":"Fix validation for entry fields in exception form (#151654)\n\n## Change validation logic for entry exception field.\r\n\r\nClose:\r\n[#143051 we didn't keep a validation state per field which caused a\r\nreset of validation if we still had invalid fields. Or we can have an\r\ninvalid state for the form, but we removed the invalid field. You can\r\nsee the videos on the ticket above.\r\n\r\n## Solution:\r\nKeep validation state per field, like:\r\n```js \r\n{\r\n [entry.id]: true,\r\n}\r\n```\r\nThis state can keep old fields, which already were removed, this is why\r\nwe use the selector to get the actual amount of errors.\r\n\r\n\r\n\r\nhttps://user-images.githubusercontent.com/7609147/220337447-95c1558c-aa85-43d1-87e8-76370aeaf141.mov\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"d93eaa010935518c45fbab1f8d57542f1ac1a83a","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Security Solution Platform","backport:prev-minor","v8.8.0"],"number":151654,"url":"#151654 validation for entry fields in exception form (#151654)\n\n## Change validation logic for entry exception field.\r\n\r\nClose:\r\n[#143051 we didn't keep a validation state per field which caused a\r\nreset of validation if we still had invalid fields. Or we can have an\r\ninvalid state for the form, but we removed the invalid field. You can\r\nsee the videos on the ticket above.\r\n\r\n## Solution:\r\nKeep validation state per field, like:\r\n```js \r\n{\r\n [entry.id]: true,\r\n}\r\n```\r\nThis state can keep old fields, which already were removed, this is why\r\nwe use the selector to get the actual amount of errors.\r\n\r\n\r\n\r\nhttps://user-images.githubusercontent.com/7609147/220337447-95c1558c-aa85-43d1-87e8-76370aeaf141.mov\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"d93eaa010935518c45fbab1f8d57542f1ac1a83a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"#151654 validation for entry fields in exception form (#151654)\n\n## Change validation logic for entry exception field.\r\n\r\nClose:\r\n[#143051 we didn't keep a validation state per field which caused a\r\nreset of validation if we still had invalid fields. Or we can have an\r\ninvalid state for the form, but we removed the invalid field. You can\r\nsee the videos on the ticket above.\r\n\r\n## Solution:\r\nKeep validation state per field, like:\r\n```js \r\n{\r\n [entry.id]: true,\r\n}\r\n```\r\nThis state can keep old fields, which already were removed, this is why\r\nwe use the selector to get the actual amount of errors.\r\n\r\n\r\n\r\nhttps://user-images.githubusercontent.com/7609147/220337447-95c1558c-aa85-43d1-87e8-76370aeaf141.mov\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"d93eaa010935518c45fbab1f8d57542f1ac1a83a"}}]}] BACKPORT--> Co-authored-by: Khristinin Nikita <nikita.khristinin@elastic.co>
Change validation logic for entry exception field.
Close: #143051
Previously we didn't keep a validation state per field which caused a reset of validation if we still had invalid fields. Or we can have an invalid state for the form, but we removed the invalid field. You can see the videos on the ticket above.
Solution:
Keep validation state per field, like:
This state can keep old fields, which already were removed, this is why we use the selector to get the actual amount of errors.
Screen.Recording.2023-02-21.at.12.49.13.mov