Preserve empty string array values in submissions#1233
Conversation
🦋 Changeset detectedLatest commit: b51f716 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📜 Recent review details🧰 Additional context used🪛 markdownlint-cli2 (0.22.1).changeset/fix-array-empty-string.md[warning] 5-5: First line in a file should be a top-level heading (MD041, first-line-heading, first-line-h1) 🔇 Additional comments (3)
📝 WalkthroughWalkthroughThis PR fixes a bug in the form submission payload builder where empty strings and other falsy-but-valid values (0, false) were being lost in array fields. The fix changes the value-merging logic to only treat ChangesEmpty string preservation in array fields
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR fixes how submission payloads are constructed for repeated (array) fields so that empty string values are preserved instead of being treated as “missing”.
Changes:
- Adjust payload aggregation logic to treat only
undefinedas “no previous value” (preserving falsy values like''). - Add a regression test covering empty strings within array fields.
- Add a changeset describing the patch fix for
@conform-to/dom.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/conform-dom/tests/submission.test.ts | Adds a test ensuring parse() preserves empty strings in repeated fields. |
| packages/conform-dom/submission.ts | Fixes array-field accumulation by not treating '' as an absent previous value. |
| .changeset/fix-array-empty-string.md | Documents the patch release and behavior change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
More templates
@conform-to/dom
@conform-to/react
@conform-to/valibot
@conform-to/validitystate
@conform-to/yup
@conform-to/zod
commit: |
parseWithZodcould drop an empty string inside an array field because that value was treated like it was absent. That can lose or shift array entries in the parsed submission payload.This narrows the presence check so only
undefinedis treated as missing. I checked it with the focusedconform-domsubmission test, changed-fileoxlint, changed-fileoxfmt --check, andgit diff --check.Closes #839
Generated Summary
Changes
Modified the presence check in
packages/conform-dom/submission.tsto preserve empty string values in array fields. The reducer now treats onlyundefinedas missing (previously treated any falsy value as missing):This ensures empty string elements in arrays are not dropped during form submission parsing, maintaining correct array indices and element ordering.
Additional updates