Skip to content

Conversation

@shierd
Copy link
Contributor

@shierd shierd commented Sep 27, 2025

Description

合并子对象时会被 form.values 的值覆盖,导致无法设置表单中子对象的值

Summary by CodeRabbit

  • Bug Fixes
    • Corrected how nested fields are merged when setting form values, preventing unintended overwrites and ensuring updates apply in the expected order.
    • Preserves special handling for Date/Dayjs values.
    • Improves reliability and predictability when updating complex form data.
    • No changes to the public API; existing forms benefit automatically without requiring code changes.

@changeset-bot
Copy link

changeset-bot bot commented Sep 27, 2025

⚠️ No Changeset found

Latest commit: 4fe0512

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 27, 2025

Walkthrough

The change updates FormApi.setValues by reversing the argument order passed to fieldMergeFn when merging nested object fields (non-Date/Dayjs). No public APIs were added or removed.

Changes

Cohort / File(s) Summary of Changes
Form merge logic
packages/@core/ui-kit/form-ui/src/form-api.ts
In setValues, when current field is an object (excluding Date/Dayjs), the recursive merge now calls fieldMergeFn(value, obj[key]) instead of fieldMergeFn(obj[key], value). Surrounding control flow unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant FormApi
  participant fieldMergeFn

  Caller->>FormApi: setValues(values)
  alt field is object (not Date/Dayjs)
    note over FormApi: New operand order for nested merge
    FormApi->>fieldMergeFn: fieldMergeFn(value, obj[key])
    fieldMergeFn-->>FormApi: mergedObject
  else non-object or special types
    FormApi-->>FormApi: assign/handle as before
  end
  FormApi-->>Caller: done
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • mynetfan
  • anncwb
  • jinmao88
  • vince292007

Poem

In burrows of code I twitch my nose,
Two args swapped where the merge now goes.
Hop, hop—objects nest just right,
Left to right becomes right to light.
Carrots compiled, tests in sight—
A tidy nibble, merge takes flight. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description only includes the Description section and lacks the required Type of change and Checklist sections prescribed by the template, so it does not fully conform to the repository’s PR description structure. Please add the missing Type of change section with the appropriate checkbox selected and complete the Checklist items to indicate testing, documentation, changelog updates, and other required validations.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly and concisely summarizes the primary change by stating that it fixes the error in merging child objects when setting form values, which directly reflects the core modification in FormApi.setValues.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81bb745 and 4fe0512.

📒 Files selected for processing (1)
  • packages/@core/ui-kit/form-ui/src/form-api.ts (1 hunks)
🔇 Additional comments (1)
packages/@core/ui-kit/form-ui/src/form-api.ts (1)

345-347: Correct operand swap for deep merge

Swapping the operands ensures the incoming field value merges into the existing nested object instead of the other way around, fixing the child-object merge regression when setting form values.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jinmao88 jinmao88 merged commit 42e3de9 into vbenjs:main Sep 29, 2025
7 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants