Repository navigation
Fix saving new forms and add debug info to save error toasts - #1125
Merged
Merged
Conversation
- 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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Users reported that after creating a new form and adding questions they could not save it. There were several causes:
FormNewnavigated 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/loginright after a successful save.onSaveForm, before the form is reset.useBlockerstill sawisDirty === true, so it showed the "You have unsaved changes" dialog on the plain Save button. This affected new form templates too.value === undefined, so""was sent. The API rejected the request:{ "name": "questions[20].DisplayLogic.Value", "reason": "'Value' must not be empty." }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 withisNilOrWhitespace.DisplayLogicEditor: render the display logic validation errors (parent question, condition, value, option ids). Previously only the question number turned red.lib/debug-log.ts: the form / form template save error toasts (new, edit, translation edit) now have a Copy debug info action. It downloadsdebug log {yyyy-mm-dd}-{hh-mm-ss}.txtcontaining the base64 encoded request body. Decode it withbase64 -d "debug log ….txt" | jq. The error toast stays open until dismissed.Testing
tsc --noEmitpasses.