This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new a1142b0f915 fix(dataset): disable duplicate button when name is empty 
(#42217)
a1142b0f915 is described below

commit a1142b0f91522766c9f24b73359038f05a17f20a
Author: suvankardas216 <[email protected]>
AuthorDate: Fri Jul 24 12:54:37 2026 +0530

    fix(dataset): disable duplicate button when name is empty (#42217)
    
    Co-authored-by: AS-MAC-1123 <[email protected]>
    Co-authored-by: Evan Rusackas <[email protected]>
    Co-authored-by: Claude Fable 5 <[email protected]>
---
 .../datasets/DuplicateDatasetModal.test.tsx        | 28 ++++++++++++++++++++++
 .../features/datasets/DuplicateDatasetModal.tsx    |  6 ++++-
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git 
a/superset-frontend/src/features/datasets/DuplicateDatasetModal.test.tsx 
b/superset-frontend/src/features/datasets/DuplicateDatasetModal.test.tsx
index b869384027b..179d7546c5b 100644
--- a/superset-frontend/src/features/datasets/DuplicateDatasetModal.test.tsx
+++ b/superset-frontend/src/features/datasets/DuplicateDatasetModal.test.tsx
@@ -106,6 +106,19 @@ test('modal opens when dataset is provided', async () => {
   ).toBeInTheDocument();
 });
 
+test('duplicate button is disabled when modal first opens', async () => {
+  const onHide = jest.fn();
+  const onDuplicate = jest.fn();
+
+  renderModal(mockDataset, onHide, onDuplicate);
+
+  const duplicateButton = await screen.findByRole('button', {
+    name: /duplicate/i,
+  });
+
+  expect(duplicateButton).toBeDisabled();
+});
+
 test('modal does not open when dataset is null', () => {
   const onHide = jest.fn();
   const onDuplicate = jest.fn();
@@ -194,6 +207,21 @@ test('pressing Enter key triggers duplicate action', async 
() => {
   });
 });
 
+test('pressing Enter with empty input does not trigger duplicate action', 
async () => {
+  const onHide = jest.fn();
+  const onDuplicate = jest.fn();
+
+  renderModal(mockDataset, onHide, onDuplicate);
+
+  const input = await screen.findByTestId('duplicate-modal-input');
+
+  // Press Enter without typing a name
+  await userEvent.type(input, '{enter}');
+
+  // onPressEnter should not bypass the disabled state
+  expect(onDuplicate).not.toHaveBeenCalled();
+});
+
 test('modal closes when onHide is called', async () => {
   const onHide = jest.fn();
   const onDuplicate = jest.fn();
diff --git a/superset-frontend/src/features/datasets/DuplicateDatasetModal.tsx 
b/superset-frontend/src/features/datasets/DuplicateDatasetModal.tsx
index 340110031c5..b6fd8d8e8f8 100644
--- a/superset-frontend/src/features/datasets/DuplicateDatasetModal.tsx
+++ b/superset-frontend/src/features/datasets/DuplicateDatasetModal.tsx
@@ -34,7 +34,7 @@ const DuplicateDatasetModal: 
FunctionComponent<DuplicateDatasetModalProps> = ({
   onDuplicate,
 }) => {
   const [show, setShow] = useState<boolean>(false);
-  const [disableSave, setDisableSave] = useState<boolean>(false);
+  const [disableSave, setDisableSave] = useState<boolean>(true);
   const [newDuplicateDatasetName, setNewDuplicateDatasetName] =
     useState<string>('');
 
@@ -45,11 +45,15 @@ const DuplicateDatasetModal: 
FunctionComponent<DuplicateDatasetModalProps> = ({
   };
 
   const duplicateDataset = () => {
+    if (disableSave) {
+      return;
+    }
     onDuplicate(newDuplicateDatasetName);
   };
 
   useEffect(() => {
     setNewDuplicateDatasetName('');
+    setDisableSave(true);
     setShow(dataset !== null);
   }, [dataset]);
 

Reply via email to