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

InputMask somehow clears the initial value to empty string #290

Closed
wanglin86769 opened this issue Apr 23, 2020 · 0 comments
Closed

InputMask somehow clears the initial value to empty string #290

wanglin86769 opened this issue Apr 23, 2020 · 0 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@wanglin86769
Copy link

I am using InputMask to display and input date value as yyyy-mm-dd string, and my initial value is fetched from a backend API using axios as promise. I found that InputMask will automatically clear the initial value to empty string when the promise delay is within specific timing.

The detailed issue description is as follows:

  1. If I display value using InputMask when the promise delay is about 10ms, the issue occurs.
  2. If I display value using another component InputText when the promise delay is about 10ms, the issue is gone.
  3. If I display value using InputMask when the promise delay is about 20ms, the issue is gone.
<template>
    <div>
        <Button label="Test" @click="print" />

        <!-- Using InputMaks -->
        <label>dateOfBirth: </label><InputMask mask="9999-99-99" v-model="user.dateOfBirth" />
        <label>dateOfWork: </label><InputMask mask="9999-99-99" v-model="user.dateOfWork" />

        <!-- Using InputText -->
        <!-- <label>dateOfBirth: </label><InputText type="text" v-model="user.dateOfBirth" />
        <label>dateOfWork: </label><InputText type="text" v-model="user.dateOfWork" /> -->
    </div>
</template>

<script>

export default {
    data() {
        return {
            user: {}
        }
    },
    created() {
        /*** No promise ***/
        // this.user = { dateOfBirth: '1985-01-01', dateOfWork: '2013-01-01' }
        // console.log(this.user.dateOfBirth);
        // console.log(this.user.dateOfWork);
             
        /*** Promise with 10ms delay ***/
        setTimeout(() => {
             this.user = { dateOfBirth: '1985-01-01', dateOfWork: '2013-01-01' }
             console.log(this.user.dateOfBirth);
			 console.log(this.user.dateOfWork);
        }, 10);

        /***  Promise with 20ms delay ***/
        // setTimeout(() => {
        //      this.user = { dateOfBirth: '1985-01-01', dateOfWork: '2013-01-01' }
        //      console.log(this.user.dateOfBirth);
		// 	 console.log(this.user.dateOfWork);
        // }, 20);
    },
    methods: {
        print() {
			console.log(this.user.dateOfBirth);
			console.log(this.user.dateOfWork);
		}
    }
}
</script>

<style scoped>

</style>

inputmask

@wanglin86769 wanglin86769 changed the title InputMak somehow clears the initial value as empty string InputMask somehow clears the initial value as empty string Apr 23, 2020
@wanglin86769 wanglin86769 changed the title InputMask somehow clears the initial value as empty string InputMask somehow clears the initial value to empty string Apr 23, 2020
@cagataycivici cagataycivici self-assigned this Apr 23, 2020
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Apr 23, 2020
@cagataycivici cagataycivici added this to the 1.3.2 milestone Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

3 participants