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

Typed phone number is erased after one letter #444

Open
kamilwylegala opened this issue Feb 19, 2024 · 0 comments
Open

Typed phone number is erased after one letter #444

kamilwylegala opened this issue Feb 19, 2024 · 0 comments

Comments

@kamilwylegala
Copy link

Hey, I stumbled upon one issue during migration to Vue3 version of the component.

Component is mounted accordingly to the docs. But typed phone number doesn't show up in the input. I type one number in input, and after another hit in the keyboard number gets erased. I'm unable to type full number.

I copied the source code of the VueTelInput into my project and debugged the issue. It's coming from having both bindings of v-model="phone" and :value="modelValue" on <input>. Always when phone gets updated it gets overridden later with modelValue that has previous state of the phone number. Although in my Vue 3 setup I'm using Options API, not sure if it's related.

Is there any particular reason why both :value and v-model are needed?

If I do following:

 <input v-model="phone"
           ref="input"
           :type="inputOptions.type"
           :autocomplete="inputOptions.autocomplete"
           :autofocus="inputOptions.autofocus"
           :class="['vti__input', inputOptions.styleClasses]"
           :disabled="disabled"
           :id="inputOptions.id"
           :maxlength="inputOptions.maxlength"
           :name="inputOptions.name"
           :placeholder="parsedPlaceholder"
           :readonly="inputOptions.readonly"
           :required="inputOptions.required"
           :tabindex="inputOptions.tabindex"
-          :value="modelValue"
           :aria-describedby="inputOptions['aria-describedby']"
           @blur="onBlur"
           @focus="onFocus"
           @input="onInput"
           @keyup.enter="onEnter"
           @keyup.space="onSpace" />

component works perfectly fine.

Thanks for the answer in the advance.

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

No branches or pull requests

1 participant