Switching between some aggregations in bucket section for sibling aggregations breaks the visualization. (#108693)
* share between aggs only field and base params: json, label, time shift. * Fix some remarks Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
fd1bf565f6
commit
bc7b2f9c59
1 changed files with 11 additions and 2 deletions
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
import { useCallback } from 'react';
|
||||
import type { SerializableRecord } from '@kbn/utility-types';
|
||||
|
||||
import { IAggConfig, AggParamType } from 'src/plugins/data/public';
|
||||
|
||||
|
@ -20,7 +21,7 @@ function useSubAggParamsHandlers(
|
|||
) {
|
||||
const setAggParamValue = useCallback(
|
||||
(aggId, paramName, val) => {
|
||||
const parsedParams = subAgg.toJSON();
|
||||
const parsedParams = subAgg.serialize();
|
||||
const params = {
|
||||
...parsedParams,
|
||||
params: {
|
||||
|
@ -36,10 +37,18 @@ function useSubAggParamsHandlers(
|
|||
|
||||
const onAggTypeChange = useCallback(
|
||||
(aggId, aggType) => {
|
||||
const parsedAgg = subAgg.toJSON();
|
||||
const parsedAgg = subAgg.serialize();
|
||||
const parsedAggParams = parsedAgg.params as SerializableRecord;
|
||||
|
||||
// we should share between aggs only field and base params: json, label, time shift.
|
||||
const params = {
|
||||
...parsedAgg,
|
||||
params: {
|
||||
field: parsedAggParams.field,
|
||||
json: parsedAggParams.json,
|
||||
customLabel: parsedAggParams.customLabel,
|
||||
timeShift: parsedAggParams.timeShift,
|
||||
},
|
||||
type: aggType,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue