fix(admin-form): show unsupported field error#9734
Conversation
|
Note Great work! All the policy violations detected earlier were successfully resolved. |
cfe13f9 to
b5690cf
Compare
LoneRifle
left a comment
There was a problem hiding this comment.
lgtm otherwise. Add the i18n in a separate commit as requested, and respond to whatever Copilot brings up.
| <InlineMessage m="1.5rem" role="alert" variant="error"> | ||
| Unable to edit this field type ({fieldType}). Please contact support if | ||
| this issue persists. | ||
| </InlineMessage> |
There was a problem hiding this comment.
Consider adding i18n here
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR replaces a developer-facing fallback in the admin edit-field drawer with a user-facing “unsupported field type” error state and adds tests to prevent regressions.
Changes:
- Replace the
TODO: Insert field options herefallback with an inline error message for unsupported/unhandled field types. - Add an explicit unsupported handler for
BasicField.Childrenand a TypeScript exhaustivenevercheck for compile-time coverage. - Add Vitest coverage for unsupported children fields and unregistered runtime field types.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignDrawer/EditFieldDrawer/EditFieldDrawer.tsx | Introduces an inline unsupported-field message and updates the switch to be exhaustive. |
| apps/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignDrawer/EditFieldDrawer/EditFieldDrawer.test.tsx | Adds tests ensuring unsupported field types render an error instead of placeholder text. |
Problem
Closes #9539
When
MemoFieldDrawerContentreceives aBasicFieldvalue without a matching switch case, the edit drawer previously rendered raw developer placeholder text:TODO: Insert field options here. This could be visible to admin users instead of a proper user-facing state.Solution
Replaced the placeholder fallback with a graceful unsupported field error state in the edit drawer. The switch now stores
field.fieldTypeinfieldType, handles known unsupportedBasicField.Children, and uses a TypeScript exhaustivenevercheck in the default branch so newly addedBasicFieldvalues must be handled at compile time.Breaking Changes
Features:
Improvements:
UnsupportedFieldTypeMessagefor field types that cannot be edited.BasicFieldcases are caught by TypeScript.Bug Fixes:
TODO: Insert field options herefallback fromMemoFieldDrawerContent.Before & After Screenshots
BEFORE:
AFTER:
Tests
Targeted test:
cd apps/frontend ./node_modules/.bin/vitest run src/features/admin-form/create/builder-and-design/BuilderAndDesignDrawer/EditFieldDrawer/EditFieldDrawer.test.tsx