Skip to content

[Live] Fixed bug with "unsynced" inputs and <form data-model> #523

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

Merged

Conversation

weaverryan
Copy link
Member

Q A
Bug fix? yes
New feature? no
Tickets none
License MIT

This fixes an unreleased bug. In a somewhat edge-case use with forms, as you typed into the fields, the values you were typing would get run-over/replaced by the old values from the server - i.e. some of what you are typing gets deleted as you type. That ends up being 0️⃣ fun!

The technical details:

If a field is modified during an Ajax request, previously, for model fields, after re-rendering, the modified values from the ValueStore were set back onto those fields via SetValueOntoModelFieldsPlugin. Effectively, morphdom would use the new value from the server (which is not correct) momentarily, and then we would reset it back to the modified value.

However, that didn't work for fields inside of a

that use the name attribute, as the "auto-set model field values" functionality purposely doesn't apply to those.

So, the system was made smarter. It now keeps track of all field elements that have been modified (i.e. are unsynced). Then, only when those values are actually sent to the server on an Ajax request, those are removed as unsynced elements. This means that morphdom will now see all unsynced fields during re-rendering and will prefer the browser values over the server values.

Cheers!

@weaverryan weaverryan force-pushed the live-fix-unsynced-form-fields-bug branch from 61e5005 to 2bdd092 Compare November 4, 2022 13:17
@weaverryan weaverryan force-pushed the live-fix-unsynced-form-fields-bug branch from 2bdd092 to ecf124f Compare November 4, 2022 13:40
@weaverryan weaverryan merged commit 2a49974 into symfony:2.x Nov 4, 2022
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.

1 participant