Skip to content

Commit

Permalink
[Lens] Do not reset formatting when switching between custom ranges a…
Browse files Browse the repository at this point in the history
…nd auto histogram (#82694) (#83034)
  • Loading branch information
flash1293 authored Nov 10, 2020
1 parent a3d53ce commit 61e2af3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
});
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down

0 comments on commit 61e2af3

Please sign in to comment.