You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above code, the formData.type logged to the console is not the one that has just been selected. It is the one prior the new selection.
This is because, the ElementInternals form data synchronization is done asynchronously: in the updated stage of the Lit component lifecycle. (see the implementation of the updated method of cc-form-control-element.abstract.js).
Could we find a way to do the ElementInternals form data synchronization synchronously?
this implies that each form control component may need to change their internal value AND also ask for form data synchronization. (which is not very developer friendly neither)
Should we make sure we always wait for the next render before handling the form submission?
we could wait for next render inside the form-submit-handler.js (or maybe in the form-submit-directive.js).
At these points we do not have a reference to the component that we should wait for render, so we could,
try to find the first LitElement in the ascendants
just use a setTimeout(fn, 0).
If we cannot find a good solution, we should at least document this somewhere.
The text was updated successfully, but these errors were encountered:
Let say you have a
<cc-select>
inside a<form>
and you want to submit the form immediately after the selection changes:In the above code, the
formData.type
logged to the console is not the one that has just been selected. It is the one prior the new selection.This is because, the
ElementInternals
form data synchronization is done asynchronously: in theupdated
stage of the Lit component lifecycle. (see the implementation of theupdated
method ofcc-form-control-element.abstract.js
).So, to make this work, we need to write:
And this is not very developer friendly!
ElementInternals
form data synchronization synchronously?value
AND also ask for form data synchronization. (which is not very developer friendly neither)form-submit-handler.js
(or maybe in theform-submit-directive.js
).LitElement
in the ascendantssetTimeout(fn, 0)
.The text was updated successfully, but these errors were encountered: