Skip to content

fix(duplications): secret key file has old form name#9248

Open
ketanwani wants to merge 1 commit intoopengovsg:developfrom
ketanwani:fix/duplicate-form-secret-key-filename
Open

fix(duplications): secret key file has old form name#9248
ketanwani wants to merge 1 commit intoopengovsg:developfrom
ketanwani:fix/duplicate-form-secret-key-filename

Conversation

@ketanwani
Copy link
Copy Markdown

@ketanwani ketanwani commented Mar 29, 2026

Problem

After a storage mode form is duplicated, the dashboard query is invalidated and refetches. When the refetch completes, dashboardForms changes (now includes the newly created form), causing the useEffect in DupeFormWizardProvider to fire again and call reset() with a newly-generated title based on the original form name. This overwrites the form state title, so the SaveSecretKeyScreen reads the wrong title via useWatch and names the downloaded secret key file incorrectly.

Fixes #9050

Solution

Guard the reset() call so it only runs while on the Details step (i.e. before the form has been created and the wizard has advanced to the save secret key screen).

Changes

  • DupeFormWizardProvider.tsx — add currentStep !== CreateFormFlowStates.Details guard to the useEffect
  • DupeFormWizardProvider.test.tsx — add tests covering the bug scenario and the fix

Test plan

  • Duplicate a storage mode form and proceed to the Save Secret Key screen — verify the downloaded file is named after the duplicate title, not the original
  • Unit tests pass: npx vitest run src/features/workspace/components/DuplicateFormModal/DupeFormWizardProvider.test.tsx
output.mp4

🤖 Generated with Claude Code

After a storage mode form is duplicated, the dashboard query is
invalidated and refetches. When the refetch completes, dashboardForms
changes (now includes the newly created form), causing the useEffect in
DupeFormWizardProvider to fire again and call reset() with a
newly-generated title based on the original form name. This overwrites
the form state title, so the SaveSecretKeyScreen reads the wrong title
via useWatch and names the downloaded file incorrectly.

Fix by guarding the reset() call so it only runs while on the Details
step (i.e., before the form has been created and we've moved to the
save secret key screen).

Fixes opengovsg#9050

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(duplications): secret key file has old form name

1 participant