Skip to content

Conversation

@kevinkim-ogp
Copy link
Contributor

@kevinkim-ogp kevinkim-ogp commented Dec 3, 2025

Problem

  • Forms that contain Section or Image fields cannot preview their table rows due to a mismatch in the Zod schema.
    The current schema allows undefined, but these field types return null, which causes validation errors.
  • If there is more than 1 table in the form, the preview always shows data from the first table

Solution

  • Replace .optional() with .nullish() so that both undefined and null are accepted.
  • Fetch the table data using the variable id

Tests

  • All FormSG test results display correctly
  • FormSG tables can be previewed correctly even when they contain section headers or images
  • FormSG table previews display the correct data when there are two or more tables

@kevinkim-ogp kevinkim-ogp requested a review from a team as a code owner December 3, 2025 06:29
@kevinkim-ogp kevinkim-ogp changed the title fix(formsg-frontend): make answer field nullish fix(formsg-frontend): table field preview Dec 3, 2025
@kevinkim-ogp kevinkim-ogp changed the title fix(formsg-frontend): table field preview PLU-624: fix(formsg-frontend): table field preview Dec 3, 2025
@linear
Copy link

linear bot commented Dec 3, 2025

Copy link
Contributor

@pregnantboy pregnantboy left a comment

Choose a reason for hiding this comment

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

thanks for quick fix 🙏🏻

@kevinkim-ogp kevinkim-ogp merged commit 5f25880 into develop-v2 Dec 3, 2025
12 checks passed
@kevinkim-ogp kevinkim-ogp deleted the fix/cannot-preview-formsg-table branch December 3, 2025 09:13
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.

3 participants