[Discover][Visualize] Fix visualizing a selected field in discover search#61226
Conversation
|
Pinging @elastic/kibana-app (Team:KibanaApp) |
|
I would suggest fixing it instead inside the diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.ts
index 0ba936c9f6..91b6a2368f 100644
--- a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.ts
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.ts
@@ -132,8 +132,10 @@ export class Vis {
this.data.savedSearchId = state.data.savedSearchId;
}
if (state.data && state.data.aggs) {
- let configStates = state.data.aggs;
- configStates = this.initializeDefaultsFromSchemas(configStates, this.type.schemas.all || []);
+ const configStates = this.initializeDefaultsFromSchemas(
+ cloneDeep(state.data.aggs),
+ this.type.schemas.all || []
+ );
if (!this.data.indexPattern) {
if (state.data.aggs.length) {
throw new Error('trying to initialize aggs without index pattern'); |
Agree! |
kertal
left a comment
There was a problem hiding this comment.
Thx for fixing this so quickly! Could you add a functional test for that, the maps team recently added one for linking geo point fields to maps. Would be nice to catch this kinds of errors in the future.
Good call @kertal ! I'd kindly ask @dmlemeshko to take a look at functional tests changes! 🙂 |
kertal
left a comment
There was a problem hiding this comment.
Code LGTM, tested locally in chrome, thx a lot for the functional test!
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
dmlemeshko
left a comment
There was a problem hiding this comment.
LGTM. I ran broken scripted fields and the newly added tests against Istanbul-instrumented Kibana and both are passing. Thank you for the fix!
…arch (elastic#61226) * Fix visualize a discover search * Move deep clone into vis.ts * Add functional tests * Fix passing filters to visualize * Revert fixing filters
…arch (elastic#61226) * Fix visualize a discover search * Move deep clone into vis.ts * Add functional tests * Fix passing filters to visualize * Revert fixing filters
Summary
Fixes #61213
Fixes #61103
Data should be deep cloned since the object is freezed on mutations.
The mutation was occurred in
AggConfig.ensureIdswhile creating newAggConfigsobject .Checklist
Delete any items that are not applicable to this PR.
For maintainers