-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[indexPatterns] update field in place #11966
Conversation
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.
Looks great! Funny how such a small change makes such a big difference in the UX. Had one thought, but it's nothing earth-shaking.
fields.push(field); | ||
const index = fields.findIndex(f => f.name === field.name); | ||
if (index > -1) { | ||
fields.splice(index, 1, field); |
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.
You could also assign to the index, might be simpler to read:
fields[index] = field;
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.
Good call, didn't think about that. I'm generally hesitant to use assignment with arrays, but since the index is coming from .findIndex()
it should be good, and I agree that it will be easier to read.
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.
Welp, actually, since indexPatterns.fields
is an indexed array assignment doesn't work 😬
@spalger I'm focusing on the cross cluster search PRs atm, you may wanna assign this to someone else if you'd like it reviewed in parallel otherwise it'll take me a couple few days to get to it. |
@Bargs no worries, it's super small. I'm good with a single reviewer. |
8131fc3
to
52eb84c
Compare
(cherry picked from commit df2fb14)
5.5/5.x: fe5abb2 |
When saving updates to a field in an index pattern the field is currently moved to the bottom of the field list, this change causes the field to be replaced in-place instead.