Skip to content

Commit

Permalink
[Lens] Fix error when selecting the current field again (#84817)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wylie Conlon authored Dec 3, 2020
1 parent 61fdec2 commit 47917b3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,24 @@ describe('IndexPatternDimensionEditorPanel', () => {
);
});

it('should not update when selecting the current field again', () => {
wrapper = mount(<IndexPatternDimensionEditorComponent {...defaultProps} />);

const comboBox = wrapper
.find(EuiComboBox)
.filter('[data-test-subj="indexPattern-dimension-field"]');

const option = comboBox
.prop('options')![1]
.options!.find(({ label }) => label === 'timestampLabel')!;

act(() => {
comboBox.prop('onChange')!([option]);
});

expect(setState).not.toHaveBeenCalled();
});

it('should show all operations that are not filtered out', () => {
wrapper = mount(
<IndexPatternDimensionEditorComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,12 @@ export function FieldSelect({
return;
}

trackUiEvent('indexpattern_dimension_field_changed');
const choice = (choices[0].value as unknown) as FieldChoice;

onChoose((choices[0].value as unknown) as FieldChoice);
if (choice.field !== selectedField) {
trackUiEvent('indexpattern_dimension_field_changed');
onChoose(choice);
}
}}
renderOption={(option, searchValue) => {
return (
Expand Down

0 comments on commit 47917b3

Please sign in to comment.