Vue component: Fix changeValidity event when there is an initial value
I am having trouble working with the changeValidity event. I would like to set the initial value when the number is empty to true and when not empty it should set wasPreviouslyValid to isValid(), see my change in this PR...
Maybe @carlssonemil can take a look?
The thing is, when pasting an invalid number into the input, I will not get "notified" that the phone number is invalid, because changeValidity is not triggered (because the initial value of wasPreviouslyValid is false).
I did not write that specific code (wasPreviouslyValid) so I'm not entirely sure why it is needed at all. Can't we always do the isValid check when the value changes and emit it, @jackocnr? I.e. remove the wasPreviouslyValid logic? 🤔
I did not write that specific code (
wasPreviouslyValid) so I'm not entirely sure why it is needed at all. Can't we always do theisValidcheck when the value changes and emit it, @jackocnr? I.e. remove thewasPreviouslyValidlogic? 🤔
@carlssonemil @jackocnr yes that would be nice :D
the same as https://github.com/jackocnr/intl-tel-input/pull/1980
Hi @bettysteger @carlssonemil @joaovinicius
Apologies for the delay in getting back to you, life has gotten in the way, but I'm here now.
Disclaimer: I have zero experience with Vue, so will leave the decision-making to you, the experts!
The initial code for this Vue component, including the wasPreviouslyValid bit, was written by the wonderful @mdpoulter
here: https://github.com/jackocnr/intl-tel-input/issues/1746#issuecomment-2292070527 so he's the best person to discuss that with.
Please let me know how you want me to proceed: if I should merge this, or @joaovinicius's PR #1980 or if we should try removing the wasPreviouslyValid code, or if we need to discuss that more first... just let me know - I'm at your service.
Edit: is this also relevant? https://github.com/jackocnr/intl-tel-input/issues/2023
If either PR (this or #1980) solves the problem I'm fine with merging either of them - or perhaps both since I don't think they will interfere with each other. Both looks good to me!
But we could also probably remove the wasPreviouslyValid code and do the valid check on each update instead, if @mdpoulter doesn't have a valid reason to keep it that I'm unaware of? We should discuss this first with him though, I could be missing something.
Edit: is this also relevant? #2023
Yes, seems like it.
Thanks for merging!
Thanks for this work! Released in v25.4.4.