Commit 0e8ff28
[Security solution][Alerts] Fix alerts page controls (elastic#236756)
## Summary
Fixes elastic#231286
## π Problem overview
As explained in the linked ticket above, there is a bug on the alert's
page controls (the filters on top of the page).
Basically, after the user re-orders and edits the available controls
(e.g. removes a field) and then tries to reset the controls, some of the
controls gets duplicated.
It doesn't happens always, but only with a specific combination of
edits. The one described in the ticket is:
- move the "status" control to the end
- delete the "user" control
- save, then reset the controls
The result of this is a duplicated "host" control where the "user"
control should be.
## π‘ Solution
The issue appear to lie on the reset callback.
In this callback there's a loop that goes through the `initialControls`,
which are the ones displayed by default before any user modification.
In this loop, a new "controls state" get generated, but somehow the code
also calls `controlGroup?.updateInput(newInput);` on every loop.
This doesn't make sense, as we are building the state and we want to set
it only once we have it all.
Moving `controlGroup?.updateInput(newInput);` outside of the loop seems
to have solve the issue.
## π To keep in mind
I myself don't fully understand why this fix is working. I tried to deep
dive into the `controlGroup` APIs but it was too deep a rabbit hole for
me to follow
Also, this PR seems to be fixing also another related bug: elastic#226987
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>1 parent 7ff3b05 commit 0e8ff28
2 files changed
Lines changed: 2 additions & 2 deletions
File tree
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | 73 | | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| |||
0 commit comments