diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx
index c8a8ffa7b128f..d43a905434c02 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx
@@ -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(
+
+ );
+
+ // 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 },
+ });
+ });
});
});
});
diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx
index 1050eef45a71c..46d9e4e6c22de 100644
--- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx
+++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx
@@ -225,7 +225,7 @@ export const rangeOperation: OperationDefinition