fix: survey question edit link resolves to a doubled survey/ segment - #626
Merged
Merged
Conversation
SurveyListItem built its link target as `survey/edit?...`, which was correct under react-router v5: relative resolution dropped the last path segment, so from /templates/job_template/1/survey the target became .../survey/edit. v6 resolves a relative target against the current route path treated as a directory, so the same string now appends and produces .../survey/survey/edit. TemplateSurvey registers only add, edit and an index route with no "*" fallback, so the unmatched remainder renders nothing and the survey screen comes up blank with no error. The list renders from the index route of survey/*, so dropping the prefix resolves correctly. The existing href assertion mounted the item at the router root, where relative resolution had nothing to append to, and so passed against the broken component. Mount it inside the same survey/* parent plus index child the app uses, and cover the question-name link, which had no test at all.
cigamit
approved these changes
Aug 10, 2026
9 tasks
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.
SUMMARY
Opening a survey question, either by clicking the question name or the pencil action,
navigates to a path containing
survey/twice and renders an empty card. No error isshown and nothing is logged.
SurveyListItembuilds a relative link target:This was correct under react-router v5, which resolved a relative target with
resolvePathname. That treats the last segment of the current path as a file and dropsit, so from
/templates/job_template/1/surveythe target became/templates/job_template/1/survey/edit.v6 resolves a relative target against the current route path treated as a directory, so
the same string now appends instead of replacing. The link has been broken since the v5 to
v6 migration; it was missed when the Template route trees were converted in #427.
The fix drops the
survey/prefix from both targets. The list renders from the index routeof
survey/*, so a plainedit?...resolves to<template>/survey/edit.Design note: the prefix could instead have been made absolute, matching
SurveyToolbar,which builds
pathname.substr(0, pathname.indexOf('survey')) + 'survey'and is why addinga question still works today. The relative form was kept because it is the idiom the rest
of the converted route trees use, and it stays correct if the survey routes are ever
mounted at a different depth.
ISSUE TYPE
COMPONENT NAME
ASCENDER VERSION
ADDITIONAL INFORMATION
Affects job templates and workflow job templates, since
Template.jsandWorkflowJobTemplate.jsboth mountTemplateSurveyatsurvey/*.TemplateSurveyregistersadd,editand an index route with nopath="*"fallback, sothe unmatched
survey/editremainder renders nothing.Template.jsalso hides the tabswhenever the path contains
survey/. That combination is why the failure presents as ablank card rather than a not-found.
Why the existing test did not catch it.
SurveyListItem.test.jsmounted the componentat the router root, with no
/templates/:templateType/:id/surveyroute above it, andasserted the href was
/survey/edit?question_variable=buzz. Relative resolution hadnothing to append to, so the assertion passed while the real screen was broken. The test
helper now mounts the item inside the same nesting the app uses, a
survey/*parent withan index child, so the assertions exercise real relative resolution. The question-name link
had no coverage at all and now has some.
Steps to reproduce
survey/segment and the card is empty.After: the edit form loads.
Before — new tests against the unfixed component:
After — same tests with the fix, then the full Template suite:
Not addressed here. Two adjacent issues, left out to keep this reviewable:
canEdit, butTemplateSurveyonlyregisters the
editroute whencanEditis true, so a user without edit or deletecapability on the template gets a dead link. This predates the router migration and is
unchanged by this PR.
TemplateSurveyhas nopath="*"fallback, so any future route mismatch will also failsilently instead of rendering
ContentError.Happy to fold either in if you would prefer them here.