Skip to content

fix(Form): parent not getting dirty after nested field is changed#6545

Open
rdjanuar wants to merge 6 commits into
nuxt:v4from
rdjanuar:fix/form-dirty-fields
Open

fix(Form): parent not getting dirty after nested field is changed#6545
rdjanuar wants to merge 6 commits into
nuxt:v4from
rdjanuar:fix/form-dirty-fields

Conversation

@rdjanuar

@rdjanuar rdjanuar commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Resolves #5144

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@rdjanuar rdjanuar requested a review from benjamincanac as a code owner June 3, 2026 13:13
@github-actions github-actions Bot added the v4 #4488 label Jun 3, 2026
@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5bd037a7-e6c0-4e31-b72c-e54004cf3c39

📥 Commits

Reviewing files that changed from the base of the PR and between 8215897 and 1f1de6b.

📒 Files selected for processing (2)
  • src/runtime/components/Form.vue
  • test/components/Form.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/components/Form.spec.ts
  • src/runtime/components/Form.vue

📝 Walkthrough

Walkthrough

This PR updates the Form component's dirty computed property to propagate nested form dirty states to the parent form. Previously, the dirty API only checked local field changes; now it also evaluates whether any attached nested form reports itself as dirty. A corresponding test validates that modifying a nested field correctly updates the parent form's dirty status.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main issue being fixed: parent form not becoming dirty when nested fields change.
Description check ✅ Passed The description links to the relevant GitHub issue (#5144) and identifies the change as a bug fix, providing context for the fix.
Linked Issues check ✅ Passed The code changes fully address the requirement from issue #5144: the modified dirty computed property now reflects nested form dirty states alongside local dirty fields.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the nested form dirty state propagation issue; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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.

@pkg-pr-new

pkg-pr-new Bot commented Jun 3, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxt/ui@6545

commit: 2701a8d

Comment thread src/runtime/components/Form.vue Outdated
if (dirtyFields.size > 0) return true

for (const form of nestedForms.value.values()) {
if ((form.api.dirty as any).value) return true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we really need this as any cast? 🤔

Suggested change
if ((form.api.dirty as any).value) return true
if (form.api.dirty.value) return true

@rdjanuar rdjanuar Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes somehow dirty field doesnt infering type ComputedRef. i think i can casting the type to be as unknown as ComputedRef<boolean> instead of any
Screenshot 2026-06-04 at 16 59 32

@rdjanuar rdjanuar force-pushed the fix/form-dirty-fields branch from 027f153 to ab758a9 Compare June 4, 2026 10:02
@rdjanuar rdjanuar requested a review from benjamincanac June 4, 2026 10:03

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/components/Form.spec.ts`:
- Around line 576-577: The test is triggering a change event without awaiting
it, which can cause async flakiness; update the test so the call to
nestedInput.trigger('change') is awaited (i.e., use await
nestedInput.trigger('change')) before calling flushPromises() to ensure the
event is fully dispatched and Vue reactivity runs; locate the trigger call on
the nestedInput element in the Form.spec.ts test and add the await.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1bac78ba-b8db-44f8-8d2d-3ad8bc17d659

📥 Commits

Reviewing files that changed from the base of the PR and between 540ebc7 and 8215897.

📒 Files selected for processing (2)
  • src/runtime/components/Form.vue
  • test/components/Form.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/runtime/components/Form.vue

Comment thread test/components/Form.spec.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested dirty UForm doesn't make it's parent dirty

2 participants