Skip to content

Fix saving new forms and add debug info to save error toasts - #1125

Merged
idormenco merged 1 commit into
mainfrom
fix/form-editor-save
Oct 19, 2026
Merged

idormenco merged 1 commit into
mainfrom
fix/form-editor-save

Conversation

@idormenco

Copy link
Copy Markdown
Contributor

Problem

Users reported that after creating a new form and adding questions they could not save it. There were several causes:

  1. Broken redirect after create. FormNew navigated to /election-rounds/{id}/forms/{formId}/edit, a route that doesn't exist (regression from Fix navigation blocker #1054). The router fell back to /election-rounds/$electionRoundId/$tab, which is PlatformAdmin-only, so NGO admins were redirected to /login right after a successful save.
  2. Unsaved-changes blocker fired during save. The redirect happens inside onSaveForm, before the form is reset. useBlocker still saw isDirty === true, so it showed the "You have unsaved changes" dialog on the plain Save button. This affected new form templates too.
  3. Empty display logic value passed client validation. The editor only checked value === undefined, so "" was sent. The API rejected the request:
    { "name": "questions[20].DisplayLogic.Value", "reason": "'Value' must not be empty." }
    The user only saw "Error creating form – please contact tech support".

Changes

  • FormNew: redirect to /forms/$formId/edit.
  • FormEditor: track an in-progress save in a ref and skip the navigation blocker while saving.
  • FormEditor: validate the display logic value with isNilOrWhitespace.
  • DisplayLogicEditor: render the display logic validation errors (parent question, condition, value, option ids). Previously only the question number turned red.
  • New lib/debug-log.ts: the form / form template save error toasts (new, edit, translation edit) now have a Copy debug info action. It downloads debug log {yyyy-mm-dd}-{hh-mm-ss}.txt containing the base64 encoded request body. Decode it with base64 -d "debug log ….txt" | jq. The error toast stays open until dismissed.

Testing

  • tsc --noEmit passes.
  • Not yet verified manually in the browser.

- Redirect to /forms/$formId/edit after creating a form. The previous
  /election-rounds/{id}/forms/{formId}/edit path does not exist and fell
  back to a PlatformAdmin-only route, sending NGO admins to /login.
- Don't trigger the unsaved-changes blocker while a save is in progress,
  so the post-create redirect is no longer blocked.
- Treat an empty display logic value as missing (the API rejects it with
  400) and show display logic validation errors in the question editor.
- Add a "Copy debug info" action to form / form template save error toasts
  that downloads the base64 encoded request body.
@vercel

vercel Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
votemonitor Ready Ready Preview Oct 19, 2026 8:24am UTC

Request Review

@idormenco
idormenco merged commit 980033f into main Oct 19, 2026
2 of 3 checks passed
@idormenco
idormenco deleted the fix/form-editor-save branch October 19, 2026 08:24

This branch was successfully deployed

1 active deployment
Preview — db9033c4 Deployed Oct 19, 2026 by vercel[bot]
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.

1 participant