Skip to content

Commit a7b8466

Browse files
denismaxim0vflash1293
authored andcommitted
[Lens] Do not reset formatting when switching between custom ranges and auto histogram (elastic#82694)
1 parent 0fcc454 commit a7b8466

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.test.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,36 @@ describe('ranges', () => {
744744
/^Bytes format:/
745745
);
746746
});
747+
748+
it('should not reset formatters when switching between custom ranges and auto histogram', () => {
749+
const setStateSpy = jest.fn();
750+
// now set a format on the range operation
751+
(state.layers.first.columns.col1 as RangeIndexPatternColumn).params.format = {
752+
id: 'custom',
753+
params: { decimals: 3 },
754+
};
755+
756+
const instance = mount(
757+
<InlineOptions
758+
{...defaultOptions}
759+
state={state}
760+
setState={setStateSpy}
761+
columnId="col1"
762+
currentColumn={state.layers.first.columns.col1 as RangeIndexPatternColumn}
763+
layerId="first"
764+
/>
765+
);
766+
767+
// This series of act closures are made to make it work properly the update flush
768+
act(() => {
769+
instance.find(EuiLink).first().prop('onClick')!({} as ReactMouseEvent);
770+
});
771+
772+
expect(setStateSpy.mock.calls[1][0].layers.first.columns.col1.params.format).toEqual({
773+
id: 'custom',
774+
params: { decimals: 3 },
775+
});
776+
});
747777
});
748778
});
749779
});

x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export const rangeOperation: OperationDefinition<RangeIndexPatternColumn, 'field
225225
type: newMode,
226226
ranges: [{ from: 0, to: DEFAULT_INTERVAL, label: '' }],
227227
maxBars: maxBarsDefaultValue,
228-
format: undefined,
228+
format: currentColumn.params.format,
229229
parentFormat,
230230
},
231231
},

0 commit comments

Comments
 (0)