Open ekwoka opened 4 months ago
Hey @ekwoka - can you provide a clearer explanation of what this PR is doing? Thanks. (also, clever approach: decorating the forceModelUpdate method)
You got it! 👍
@ekwoka Hey Eric, does this fix also fixes the bug with the native user-valid/user-invalid ? As per this discussion: https://github.com/alpinejs/alpine/discussions/4046
It shouldn't impact that at all.
Alright, that's a still a problem then. Thanks for this PR though!
Ran into this issue just now. Going to have to figure out an alternate solution until this PR is merged as I need the mask to apply both with manual and programmatic updates.
When will this PR be merged?
Solves #3691
Problem
When a value modeled onto an input with x-mask is updated on the data side (not via the masked input itself), the mask is not processing and masking the value. Most commonly this will be common with $money where the programmatically updated value is likely to just be a raw number or number string.
Demo
Solution
This checks for and wraps the x-model forced update method to retrigger the masking on the value and push it back into the model.
Not exactly pretty. I can do a more significant refactoring of the directive to make this cleaner, but this basically shows what steps aren't being handled.
Tests
This includes a bespoke test, as well as passes a previous disabled test (which is now enabled) that seemed to run into this issue in a flaky manner