mirror of
https://github.com/apache/superset.git
synced 2026-06-04 07:09:22 +00:00
fix: Make Select component fire onChange listener when a selection is pasted in (#25993)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -554,6 +554,7 @@ const AsyncSelect = forwardRef(
|
||||
...values,
|
||||
]);
|
||||
}
|
||||
fireOnChange();
|
||||
};
|
||||
|
||||
const shouldRenderChildrenOptions = useMemo(
|
||||
|
||||
@@ -985,6 +985,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(<Select {...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(
|
||||
<Select
|
||||
|
||||
@@ -571,6 +571,7 @@ const Select = forwardRef(
|
||||
]);
|
||||
}
|
||||
}
|
||||
fireOnChange();
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user