Skip to content

Commit

Permalink
Add fix for AsyncSelect
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrag1 committed Nov 15, 2023
1 parent 290ac14 commit 330eb61
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions superset-frontend/src/components/Select/AsyncSelect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,20 @@ test('fires onChange when clearing the selection in multiple mode', async () =>
expect(onChange).toHaveBeenCalledTimes(1);
});

test('fires onChange when pasting a selection', async () => {
const onChange = jest.fn();
render(<AsyncSelect {...defaultProps} onChange={onChange} />);
await open();
const input = getElementByClassName('.ant-select-selection-search-input');
const paste = createEvent.paste(input, {
clipboardData: {
getData: () => OPTIONS[0].label,
},
});
fireEvent(input, paste);
expect(onChange).toHaveBeenCalledTimes(1);
});

test('does not duplicate options when using numeric values', async () => {
render(
<AsyncSelect
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/src/components/Select/AsyncSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ const AsyncSelect = forwardRef(
...values,
]);
}
fireOnChange();
};

const shouldRenderChildrenOptions = useMemo(
Expand Down

0 comments on commit 330eb61

Please sign in to comment.