Fix for masking when input value is established on component mount #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
On the entries page, if you have a form with formatted text fields (ex: phone, zip code, etc.) and you switch from editing an existing entry (with a value in that field) to creating a new entry, the form for the new entry will appear to have the value from the existing entry that you were editing.
When the mask directive's
bind
method is called, it callsupdateValue
which mask's the input's value and updates it and raises an input event if needed. This typically isn't relevant to us since we store formatted values, but it also has the side-effect of setting theoldValue
in the config. A subsequentupdate
call will callupdateValue
, which checksoldValue
to determine if the value has changed. IfoldValue
was never established, at that point it will think the value is different and as a result mask the value and raise an input event. It appears this happens because the element input component doesn't set the value via a binding, but instead does it programmatically in themounted
hook. I believe this is what causes both the input not having a value inbind
, as well as the value being stale whenupdate
is called.Checklist