[Lens] Do not reset formatting when switching between custom ranges and auto histogram (#82694)

This commit is contained in:
Denis Maximov 2020-11-10 12:25:28 +02:00 committed by GitHub
parent 1de3a02a46
commit 0503f873f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View file

@ -744,6 +744,36 @@ describe('ranges', () => {
/^Bytes format:/
);
});
it('should not reset formatters when switching between custom ranges and auto histogram', () => {
const setStateSpy = jest.fn();
// now set a format on the range operation
(state.layers.first.columns.col1 as RangeIndexPatternColumn).params.format = {
id: 'custom',
params: { decimals: 3 },
};
const instance = mount(
<InlineOptions
{...defaultOptions}
state={state}
setState={setStateSpy}
columnId="col1"
currentColumn={state.layers.first.columns.col1 as RangeIndexPatternColumn}
layerId="first"
/>
);
// This series of act closures are made to make it work properly the update flush
act(() => {
instance.find(EuiLink).first().prop('onClick')!({} as ReactMouseEvent);
});
expect(setStateSpy.mock.calls[1][0].layers.first.columns.col1.params.format).toEqual({
id: 'custom',
params: { decimals: 3 },
});
});
});
});
});

View file

@ -225,7 +225,7 @@ export const rangeOperation: OperationDefinition<RangeIndexPatternColumn, 'field
type: newMode,
ranges: [{ from: 0, to: DEFAULT_INTERVAL, label: '' }],
maxBars: maxBarsDefaultValue,
format: undefined,
format: currentColumn.params.format,
parentFormat,
},
},