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

Fix for masking when input value is established on component mount #4

Merged
merged 5 commits into from
Jun 21, 2022

Conversation

mattheyan
Copy link

@mattheyan mattheyan commented Jun 21, 2022

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 calls updateValue 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 the oldValue in the config. A subsequent update call will call updateValue, which checks oldValue to determine if the value has changed. If oldValue 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 the mounted hook. I believe this is what causes both the input not having a value in bind, as well as the value being stale when update is called.

Checklist

  • Tests
  • Documentation
  • Used commitizen and followed Conventional Commits
  • Commit footer references issue num. If applicable.

src/directive.js Outdated Show resolved Hide resolved
@mattheyan mattheyan marked this pull request as ready for review June 21, 2022 19:58
@mattheyan mattheyan requested a review from tskimmett June 21, 2022 19:58
@tskimmett tskimmett merged commit c1777dd into master Jun 21, 2022
mattheyan added a commit that referenced this pull request Oct 7, 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.

2 participants