-
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
[EDR Workflows] Error message 'the value already exists' shown for duplicate values with the 'is one of' operator on Blocklist tab #196071
[EDR Workflows] Error message 'the value already exists' shown for duplicate values with the 'is one of' operator on Blocklist tab #196071
Conversation
Pinging @elastic/security-defend-workflows (Team:Defend Workflows) |
value: false, | ||
}); | ||
const [nameVisited, setNameVisited] = useState(false); | ||
const [valueVisited, setValueVisited] = useState({ value: false }); // Use object to trigger re-render |
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.
So take this with a grain of salt 🧂 because I haven't really touched frontend code in nearly 3 years but this feels a little bit weird. Not a blocker or anything but I do wonder if there's a better approach.
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 agree with joey here, this doesn't look like a good practice.
i guess it is needed, because warnings and errors are stored in reference values, but i don't see why we need to store those in refs instead of good ol' states. i'd suggest to try to remove the refs, and use states (or maybe one state if they always change together) to improve this file
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 the changes! it works well 👍
could you add a test to cover the fixed behaviour?
also, if you have time for it, i think it would be great to improve on this file and remove the unnecessary looking refs
value: false, | ||
}); | ||
const [nameVisited, setNameVisited] = useState(false); | ||
const [valueVisited, setValueVisited] = useState({ value: false }); // Use object to trigger re-render |
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 agree with joey here, this doesn't look like a good practice.
i guess it is needed, because warnings and errors are stored in reference values, but i don't see why we need to store those in refs instead of good ol' states. i'd suggest to try to remove the refs, and use states (or maybe one state if they always change together) to improve this file
… into fix-is-one-of-combo-box-warning
@gergoabraham I've added an unit to cover this changes. |
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.
alright, let's 🚢 it then. thanks for the tests! 🙇
💛 Build succeeded, but was flaky
Failed CI Steps
Test Failures
Metrics [docs]Async chunks
History
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
10 similar comments
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Starting backport for target branches: 8.16 |
…plicate values with the 'is one of' operator on Blocklist tab (elastic#196071) These changes ensure that the warning displayed to the user for duplicate values remains visible after onBlur. I’ve opted to keep it as a warning rather than an error since entering a duplicate value doesn’t allow the user to “save” it as a selected item in the combo box—it remains an active string in the input field. We don’t block form submission due to this warning; any unselected value in the combo box is stripped out. The red border on the combo box is part of EUI’s behavior when attempting to select a duplicate, and I don’t see an easy way to modify this at the moment. https://github.com/user-attachments/assets/84b6d8af-02a8-41f3-88dc-892ed408a098 (cherry picked from commit 99a19e7)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…x27; shown for duplicate values with the 'is one of' operator on Blocklist tab (#196071) (#199992) # Backport This will backport the following commits from `main` to `8.16`: - [[EDR Workflows] Error message 'the value already exists' shown for duplicate values with the 'is one of' operator on Blocklist tab (#196071)](#196071) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Konrad Szwarc","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-23T10:29:32Z","message":"[EDR Workflows] Error message 'the value already exists' shown for duplicate values with the 'is one of' operator on Blocklist tab (#196071)\n\nThese changes ensure that the warning displayed to the user for\r\nduplicate values remains visible after onBlur. I’ve opted to keep it as\r\na warning rather than an error since entering a duplicate value doesn’t\r\nallow the user to “save” it as a selected item in the combo box—it\r\nremains an active string in the input field. We don’t block form\r\nsubmission due to this warning; any unselected value in the combo box is\r\nstripped out. The red border on the combo box is part of EUI’s behavior\r\nwhen attempting to select a duplicate, and I don’t see an easy way to\r\nmodify this at the moment.\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/84b6d8af-02a8-41f3-88dc-892ed408a098","sha":"99a19e762daf08376828032e593a9e88befe6d23","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport missing","v9.0.0","Team:Defend Workflows","backport:version","v8.16.1"],"title":"[EDR Workflows] Error message 'the value already exists' shown for duplicate values with the 'is one of' operator on Blocklist tab","number":196071,"url":"https://github.com/elastic/kibana/pull/196071","mergeCommit":{"message":"[EDR Workflows] Error message 'the value already exists' shown for duplicate values with the 'is one of' operator on Blocklist tab (#196071)\n\nThese changes ensure that the warning displayed to the user for\r\nduplicate values remains visible after onBlur. I’ve opted to keep it as\r\na warning rather than an error since entering a duplicate value doesn’t\r\nallow the user to “save” it as a selected item in the combo box—it\r\nremains an active string in the input field. We don’t block form\r\nsubmission due to this warning; any unselected value in the combo box is\r\nstripped out. The red border on the combo box is part of EUI’s behavior\r\nwhen attempting to select a duplicate, and I don’t see an easy way to\r\nmodify this at the moment.\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/84b6d8af-02a8-41f3-88dc-892ed408a098","sha":"99a19e762daf08376828032e593a9e88befe6d23"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196071","number":196071,"mergeCommit":{"message":"[EDR Workflows] Error message 'the value already exists' shown for duplicate values with the 'is one of' operator on Blocklist tab (#196071)\n\nThese changes ensure that the warning displayed to the user for\r\nduplicate values remains visible after onBlur. I’ve opted to keep it as\r\na warning rather than an error since entering a duplicate value doesn’t\r\nallow the user to “save” it as a selected item in the combo box—it\r\nremains an active string in the input field. We don’t block form\r\nsubmission due to this warning; any unselected value in the combo box is\r\nstripped out. The red border on the combo box is part of EUI’s behavior\r\nwhen attempting to select a duplicate, and I don’t see an easy way to\r\nmodify this at the moment.\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/84b6d8af-02a8-41f3-88dc-892ed408a098","sha":"99a19e762daf08376828032e593a9e88befe6d23"}},{"branch":"8.16","label":"v8.16.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Konrad Szwarc <[email protected]>
Starting backport for target branches: 8.16, 8.x |
…plicate values with the 'is one of' operator on Blocklist tab (elastic#196071) These changes ensure that the warning displayed to the user for duplicate values remains visible after onBlur. I’ve opted to keep it as a warning rather than an error since entering a duplicate value doesn’t allow the user to “save” it as a selected item in the combo box—it remains an active string in the input field. We don’t block form submission due to this warning; any unselected value in the combo box is stripped out. The red border on the combo box is part of EUI’s behavior when attempting to select a duplicate, and I don’t see an easy way to modify this at the moment. https://github.com/user-attachments/assets/84b6d8af-02a8-41f3-88dc-892ed408a098 (cherry picked from commit 99a19e7)
💔 Some backports could not be created
Note: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
…27; shown for duplicate values with the 'is one of' operator on Blocklist tab (#196071) (#200915) # Backport This will backport the following commits from `main` to `8.x`: - [[EDR Workflows] Error message 'the value already exists' shown for duplicate values with the 'is one of' operator on Blocklist tab (#196071)](#196071) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Konrad Szwarc","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-23T10:29:32Z","message":"[EDR Workflows] Error message 'the value already exists' shown for duplicate values with the 'is one of' operator on Blocklist tab (#196071)\n\nThese changes ensure that the warning displayed to the user for\r\nduplicate values remains visible after onBlur. I’ve opted to keep it as\r\na warning rather than an error since entering a duplicate value doesn’t\r\nallow the user to “save” it as a selected item in the combo box—it\r\nremains an active string in the input field. We don’t block form\r\nsubmission due to this warning; any unselected value in the combo box is\r\nstripped out. The red border on the combo box is part of EUI’s behavior\r\nwhen attempting to select a duplicate, and I don’t see an easy way to\r\nmodify this at the moment.\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/84b6d8af-02a8-41f3-88dc-892ed408a098","sha":"99a19e762daf08376828032e593a9e88befe6d23","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Defend Workflows","backport:version","v8.17.0","v8.16.1"],"title":"[EDR Workflows] Error message 'the value already exists' shown for duplicate values with the 'is one of' operator on Blocklist tab","number":196071,"url":"https://github.com/elastic/kibana/pull/196071","mergeCommit":{"message":"[EDR Workflows] Error message 'the value already exists' shown for duplicate values with the 'is one of' operator on Blocklist tab (#196071)\n\nThese changes ensure that the warning displayed to the user for\r\nduplicate values remains visible after onBlur. I’ve opted to keep it as\r\na warning rather than an error since entering a duplicate value doesn’t\r\nallow the user to “save” it as a selected item in the combo box—it\r\nremains an active string in the input field. We don’t block form\r\nsubmission due to this warning; any unselected value in the combo box is\r\nstripped out. The red border on the combo box is part of EUI’s behavior\r\nwhen attempting to select a duplicate, and I don’t see an easy way to\r\nmodify this at the moment.\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/84b6d8af-02a8-41f3-88dc-892ed408a098","sha":"99a19e762daf08376828032e593a9e88befe6d23"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196071","number":196071,"mergeCommit":{"message":"[EDR Workflows] Error message 'the value already exists' shown for duplicate values with the 'is one of' operator on Blocklist tab (#196071)\n\nThese changes ensure that the warning displayed to the user for\r\nduplicate values remains visible after onBlur. I’ve opted to keep it as\r\na warning rather than an error since entering a duplicate value doesn’t\r\nallow the user to “save” it as a selected item in the combo box—it\r\nremains an active string in the input field. We don’t block form\r\nsubmission due to this warning; any unselected value in the combo box is\r\nstripped out. The red border on the combo box is part of EUI’s behavior\r\nwhen attempting to select a duplicate, and I don’t see an easy way to\r\nmodify this at the moment.\r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/84b6d8af-02a8-41f3-88dc-892ed408a098","sha":"99a19e762daf08376828032e593a9e88befe6d23"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/199992","number":199992,"state":"MERGED","mergeCommit":{"sha":"4c5d5fa5a40014b0d8b09d0a9d07b7a7eec899a1","message":"[8.16] [EDR Workflows] Error message 'the value already exists' shown for duplicate values with the 'is one of' operator on Blocklist tab (#196071) (#199992)\n\n# Backport\n\nThis will backport the following commits from `main` to `8.16`:\n- [[EDR Workflows] Error message 'the value already exists'\nshown for duplicate values with the 'is one of' operator on\nBlocklist tab (#196071)](https://github.com/elastic/kibana/pull/196071)\n\n<!--- Backport version: 9.4.3 -->\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT [{\"author\":{\"name\":\"Konrad\nSzwarc\",\"email\":\"[email protected]\"},\"sourceCommit\":{\"committedDate\":\"2024-10-23T10:29:32Z\",\"message\":\"[EDR\nWorkflows] Error message 'the value already exists' shown for duplicate\nvalues with the 'is one of' operator on Blocklist tab (#196071)\\n\\nThese\nchanges ensure that the warning displayed to the user for\\r\\nduplicate\nvalues remains visible after onBlur. I’ve opted to keep it as\\r\\na\nwarning rather than an error since entering a duplicate value\ndoesn’t\\r\\nallow the user to “save” it as a selected item in the combo\nbox—it\\r\\nremains an active string in the input field. We don’t block\nform\\r\\nsubmission due to this warning; any unselected value in the\ncombo box is\\r\\nstripped out. The red border on the combo box is part of\nEUI’s behavior\\r\\nwhen attempting to select a duplicate, and I don’t see\nan easy way to\\r\\nmodify this at the\nmoment.\\r\\n\\r\\n\\r\\n\\r\\nhttps://github.com/user-attachments/assets/84b6d8af-02a8-41f3-88dc-892ed408a098\",\"sha\":\"99a19e762daf08376828032e593a9e88befe6d23\",\"branchLabelMapping\":{\"^v9.0.0$\":\"main\",\"^v8.17.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"release_note:skip\",\"backport\nmissing\",\"v9.0.0\",\"Team:Defend\nWorkflows\",\"backport:version\",\"v8.16.1\"],\"title\":\"[EDR Workflows] Error\nmessage 'the value already exists' shown for duplicate values with the\n'is one of' operator on Blocklist\ntab\",\"number\":196071,\"url\":\"https://github.com/elastic/kibana/pull/196071\",\"mergeCommit\":{\"message\":\"[EDR\nWorkflows] Error message 'the value already exists' shown for duplicate\nvalues with the 'is one of' operator on Blocklist tab (#196071)\\n\\nThese\nchanges ensure that the warning displayed to the user for\\r\\nduplicate\nvalues remains visible after onBlur. I’ve opted to keep it as\\r\\na\nwarning rather than an error since entering a duplicate value\ndoesn’t\\r\\nallow the user to “save” it as a selected item in the combo\nbox—it\\r\\nremains an active string in the input field. We don’t block\nform\\r\\nsubmission due to this warning; any unselected value in the\ncombo box is\\r\\nstripped out. The red border on the combo box is part of\nEUI’s behavior\\r\\nwhen attempting to select a duplicate, and I don’t see\nan easy way to\\r\\nmodify this at the\nmoment.\\r\\n\\r\\n\\r\\n\\r\\nhttps://github.com/user-attachments/assets/84b6d8af-02a8-41f3-88dc-892ed408a098\",\"sha\":\"99a19e762daf08376828032e593a9e88befe6d23\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[\"8.16\"],\"targetPullRequestStates\":[{\"branch\":\"main\",\"label\":\"v9.0.0\",\"branchLabelMappingKey\":\"^v9.0.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/196071\",\"number\":196071,\"mergeCommit\":{\"message\":\"[EDR\nWorkflows] Error message 'the value already exists' shown for duplicate\nvalues with the 'is one of' operator on Blocklist tab (#196071)\\n\\nThese\nchanges ensure that the warning displayed to the user for\\r\\nduplicate\nvalues remains visible after onBlur. I’ve opted to keep it as\\r\\na\nwarning rather than an error since entering a duplicate value\ndoesn’t\\r\\nallow the user to “save” it as a selected item in the combo\nbox—it\\r\\nremains an active string in the input field. We don’t block\nform\\r\\nsubmission due to this warning; any unselected value in the\ncombo box is\\r\\nstripped out. The red border on the combo box is part of\nEUI’s behavior\\r\\nwhen attempting to select a duplicate, and I don’t see\nan easy way to\\r\\nmodify this at the\nmoment.\\r\\n\\r\\n\\r\\n\\r\\nhttps://github.com/user-attachments/assets/84b6d8af-02a8-41f3-88dc-892ed408a098\",\"sha\":\"99a19e762daf08376828032e593a9e88befe6d23\"}},{\"branch\":\"8.16\",\"label\":\"v8.16.1\",\"branchLabelMappingKey\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"}]}]\nBACKPORT-->\n\nCo-authored-by: Konrad Szwarc <[email protected]>"}}]}] BACKPORT--> Co-authored-by: Konrad Szwarc <[email protected]>
These changes ensure that the warning displayed to the user for duplicate values remains visible after onBlur. I’ve opted to keep it as a warning rather than an error since entering a duplicate value doesn’t allow the user to “save” it as a selected item in the combo box—it remains an active string in the input field. We don’t block form submission due to this warning; any unselected value in the combo box is stripped out. The red border on the combo box is part of EUI’s behavior when attempting to select a duplicate, and I don’t see an easy way to modify this at the moment.
Screen.Recording.2024-10-14.at.11.25.47.mov