Skip to content

Commit

Permalink
Merge pull request #484 from keen/fix/event-collection-select
Browse files Browse the repository at this point in the history
fix: 🐛 prevent reset query after selecting same event stream
  • Loading branch information
maciejrybaniec authored Oct 30, 2020
2 parents 1c99dbc + 9e6c5a2 commit 0cb1f6d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,25 @@ test('renders empty search results', () => {
getByText('query_creator_event_collection.empty_search_results')
).toBeInTheDocument();
});

test('do not calls "onChange" handler for selecting same event collection', () => {
const storeState = {
events: {
collections: ['clicks', 'logins', 'purchases'],
},
};
const {
wrapper: { getByTestId, getByText },
props,
} = render(storeState, {
collection: 'clicks',
});

const propertyField = getByTestId('dropable-container');
fireEvent.click(propertyField);

const property = getByText('clicks');
fireEvent.click(property);

expect(props.onChange).not.toHaveBeenCalled();
});
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ const EventCollection: FC<Props> = ({
items={collectionsList}
setActiveItem={(_item, idx) => selectionIndex === idx}
onClick={(_e, { value }) => {
onChange(value);
if (collection !== value) {
onChange(value);
}
setCollectionsList(options);
}}
/>
Expand Down

0 comments on commit 0cb1f6d

Please sign in to comment.