From c47f3163c35881b929913c65ae43a1cd9640ef82 Mon Sep 17 00:00:00 2001 From: Jack Fragassi Date: Thu, 16 Nov 2023 12:06:05 -0800 Subject: [PATCH] fix: Make Select component fire onChange listener when a selection is pasted in (#25993) --- .../src/components/Select/AsyncSelect.test.tsx | 14 ++++++++++++++ .../src/components/Select/AsyncSelect.tsx | 1 + .../src/components/Select/Select.test.tsx | 14 ++++++++++++++ superset-frontend/src/components/Select/Select.tsx | 1 + 4 files changed, 30 insertions(+) diff --git a/superset-frontend/src/components/Select/AsyncSelect.test.tsx b/superset-frontend/src/components/Select/AsyncSelect.test.tsx index c1442a6b70a1c..0bb24b474a0cc 100644 --- a/superset-frontend/src/components/Select/AsyncSelect.test.tsx +++ b/superset-frontend/src/components/Select/AsyncSelect.test.tsx @@ -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(); + 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( expect(onChange).toHaveBeenCalledTimes(1); }); +test('fires onChange when pasting a selection', async () => { + const onChange = jest.fn(); + render(