Skip to content

fix(admin-form): show unsupported field error#9734

Open
Strikerprv wants to merge 1 commit into
opengovsg:developfrom
Strikerprv:fix/edit-field-drawer-error-state
Open

fix(admin-form): show unsupported field error#9734
Strikerprv wants to merge 1 commit into
opengovsg:developfrom
Strikerprv:fix/edit-field-drawer-error-state

Conversation

@Strikerprv

Copy link
Copy Markdown

Problem

Closes #9539

When MemoFieldDrawerContent receives a BasicField value 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.fieldType in fieldType, handles known unsupported BasicField.Children, and uses a TypeScript exhaustive never check in the default branch so newly added BasicField values must be handled at compile time.

Breaking Changes

  • Yes - this PR contains breaking changes
    • Details ...
  • No - this PR is backwards compatible

Features:

  • N/A

Improvements:

  • Added an explicit UnsupportedFieldTypeMessage for field types that cannot be edited.
  • Added an exhaustive switch check so missing BasicField cases are caught by TypeScript.

Bug Fixes:

  • Removed the raw TODO: Insert field options here fallback from MemoFieldDrawerContent.
  • Added test coverage for unsupported non-MyInfo children fields and unregistered runtime field types.

Before & After Screenshots

BEFORE:

image

AFTER:

image

Tests

Targeted test:

cd apps/frontend
./node_modules/.bin/vitest run src/features/admin-form/create/builder-and-design/BuilderAndDesignDrawer/EditFieldDrawer/EditFieldDrawer.test.tsx

@Strikerprv
Strikerprv requested a review from a team July 8, 2026 14:02
@endor-labs-pro

endor-labs-pro Bot commented Jul 8, 2026

Copy link
Copy Markdown

Note

Great work! All the policy violations detected earlier were successfully resolved.

@Strikerprv
Strikerprv force-pushed the fix/edit-field-drawer-error-state branch from cfe13f9 to b5690cf Compare July 8, 2026 14:05

@LoneRifle LoneRifle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm otherwise. Add the i18n in a separate commit as requested, and respond to whatever Copilot brings up.

Comment on lines +121 to +124
<InlineMessage m="1.5rem" role="alert" variant="error">
Unable to edit this field type ({fieldType}). Please contact support if
this issue persists.
</InlineMessage>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding i18n here

@LoneRifle
LoneRifle requested a review from Copilot July 9, 2026 13:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 here fallback with an inline error message for unsupported/unhandled field types.
  • Add an explicit unsupported handler for BasicField.Children and a TypeScript exhaustive never check 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.

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.

[Task] Replace placeholder text with graceful error state in EditFieldDrawer for unregistered field types

4 participants