Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dirty tracking doesn't work without setting initial form values. #127

Closed
genu opened this issue Feb 6, 2025 · 2 comments · Fixed by #128
Closed

Dirty tracking doesn't work without setting initial form values. #127

genu opened this issue Feb 6, 2025 · 2 comments · Fixed by #128
Labels
🐞 bug Something isn't working ❗️ p1-high Important tasks or features with significant impact on users or the project

Comments

@genu
Copy link
Contributor

genu commented Feb 6, 2025

Describe the bug
Related discussion: #126 (comment)

To Reproduce
This bug can be seen when checking the isDirty() of a form when it doesn't have initialValues. It will always be true

Expected behavior
Form should only be dirty when fields are modified.

@genu genu added the ⏳ triage Evaluate the issue and assign the appropriate priority label label Feb 6, 2025
@logaretm logaretm added 🐞 bug Something isn't working ❗️ p1-high Important tasks or features with significant impact on users or the project and removed ⏳ triage Evaluate the issue and assign the appropriate priority label labels Feb 7, 2025
@logaretm
Copy link
Member

logaretm commented Feb 7, 2025

Looks like having any sort of nested fields (grouped or not) causes this bug to happen, top level fields work as expected.

This is because when a field is nested it creates a nested path in the form values, where in a top-level field, the initialization is skipped then.

This can still happen if the initial values didn't contain that nested path, so it would initialize itself and would then cause the dirty check to be buggy.

I'm thinking about how to approach this, but setting the original values on field init transaction is dangerous because it may not be the result of a first render, it could be a toggled field (v-if) or managed by a field repeater 🤔

Maybe instead, the dirty status should be tracked like how touched is being tracked. Manually.

@logaretm logaretm linked a pull request Feb 7, 2025 that will close this issue
@genu
Copy link
Contributor Author

genu commented Feb 7, 2025

Thanks for the thorough explanation @logaretm

I'll test the PR on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working ❗️ p1-high Important tasks or features with significant impact on users or the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants