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

Remove doesnt work on mask chars #4

Closed
Samuell1 opened this issue Oct 27, 2016 · 7 comments
Closed

Remove doesnt work on mask chars #4

Samuell1 opened this issue Oct 27, 2016 · 7 comments

Comments

@Samuell1
Copy link

Samuell1 commented Oct 27, 2016

Hi, its a way to enable removing chars from input that are in mask? (separating chars like: -, / , _,..)

@probil
Copy link
Owner

probil commented Oct 27, 2016

Hi, @Samuell1
You can delete separating chars right now without any issue.
I don't understand your question. Can you please, explain it deeper?
I'd like to solve the issue you have but I need more information

@Samuell1
Copy link
Author

Samuell1 commented Oct 28, 2016

When I try to delete text AA-####-AAAA and I start deleting using backspace from the last char, deleting stops at AA-####- ...IDK how to explain it better way, I am simply not able to delete that separator (-) without highlighting the whole AA-####-AAAA or moving behind separator with arrows on my keyboard or mouse.

@probil
Copy link
Owner

probil commented Oct 28, 2016

So, format is: AA-####-AAAA
And you are typing something like: sA-4254-DbtZ
Then you try to delete chars with backspace and you suck at sA-4254-, right?

Btw, what version are you using? For Vue 2.X or Vue 1.X?

@Samuell1
Copy link
Author

Samuell1 commented Oct 28, 2016

I am using Vue 2 and I am using only your function format() in my own custom component on input tag

@probil
Copy link
Owner

probil commented Oct 28, 2016

So, the issue is not in v-mask. But in your implementation.
Check here how I have solved the issue
In short, I have cached the length. If the previous length is longer then new one I don't call format at all. Because in this case, Backspace/Del was pressed.

Btw, v-mask now supports Vue 2.0

@Samuell1
Copy link
Author

Samuell1 commented Oct 28, 2016

I think i have same function for changing value for input

            var new_value = value

            if (this.mask) {
                var previous = ''

                if (previous.length < value.length) {
                    new_value = this.format(value, this.mask)
                    previous = new_value
                }
            }

            this.currentValue = new_value

@Samuell1
Copy link
Author

Samuell1 commented Oct 28, 2016

I find it! previous.length every time returning 0 :D . I edited it to

            var new_value = value

            if (this.mask) {
                if (this.previousValue.length < value.length) {
                    new_value = this.format(value, this.mask)
                }
                this.previousValue = new_value
            }

            this.currentValue = new_value

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

2 participants