v-mask icon indicating copy to clipboard operation
v-mask copied to clipboard

Input focuses on the input end

Open nunob87 opened this issue 8 years ago • 16 comments

When you focus on the start of the input after the first click on a key, it focuses on the input end

thanks

nunob87 avatar Jul 31 '17 10:07 nunob87

Same problem

PNKBizz avatar Aug 24 '17 07:08 PNKBizz

Having the same issue here.

Type in something in the input field, then mark some text anywhere else than the end, start typing, and the cursor / marker jumps to the end of the field. Giving a rather poor user experience.

Edit: Just noticed this issue was raised 2 years ago...still no fix for this?

akselhenriksen79 avatar Aug 08 '19 08:08 akselhenriksen79

Hi @sjobidoo It's not easy to fix. If you have an idea how to do it - create PR. I will be glad to review.

If you are not satisfied with the library to just pick another one.

probil avatar Aug 08 '19 08:08 probil

You can handle this issue with calling below method on input event

onInput(e) {
        const position = e.target.selectionStart;
          this.$nextTick(() => {
            e.target.setSelectionRange(position, position);
          });
}

AvinashChavanN avatar Aug 10 '19 18:08 AvinashChavanN

Thanks @AvinashChavanN Will check it out

probil avatar Aug 11 '19 15:08 probil

@AvinashChavanN @probil this "fix" didn't work for me. It's still jumping focus to the end. i.e. if the field has a filled out 10 digit phone number, i then highlight and deleted the first three digits, then type a digit, it still jumps to the end. I debugged and the onInput runs twice, first time it seems to maintain the position but 2nd run it jumps to the end.

clemsontiger avatar Oct 16 '19 13:10 clemsontiger

@clemsontiger thanks for your feedback! I hope I will find some time to check it myself

probil avatar Oct 16 '19 14:10 probil

@probil , sorry but any further update? Unfortunately I'm going to have to look to use a different mask library for vue as this open issue is causing too many issues.

clemsontiger avatar Dec 05 '19 14:12 clemsontiger

@clemsontiger I understand. I hope you'll find a better solution. :cat2: :wave: Unfortunately I don't have enough time to fix and investigate every issue.

probil avatar Dec 05 '19 20:12 probil

@sjobidoo , @nunob87 , @PNKBizz did either of you find a working workaround for this issue? The fix provided by @AvinashChavanN never worked for me.

clemsontiger avatar Jan 13 '20 14:01 clemsontiger

@clemsontiger we abandoned this due to this problem.

I used cleavejs instead

akselhenriksen79 avatar Jan 13 '20 14:01 akselhenriksen79

@sjobidoo okay thanks.

clemsontiger avatar Jan 14 '20 18:01 clemsontiger

This is still a problem.

zcuric avatar Oct 06 '20 12:10 zcuric

@AvinashChavanN workaround will work if If the handler will only handle only user-generated events (isTrusted property), this will prevent process action generated by v-mask reaction:

onInput(event) {
  if (event.isTrusted) {
    const position = event.target.selectionStart;
    this.$nextTick(() => {
      event.target.setSelectionRange(position, position);
    });
  }
}

But this solution will give rise to a small heap of small bugs.

subtronic avatar Jan 11 '22 14:01 subtronic

Thanks @subtronic I'll try that out and include in the next release if it works without issues

probil avatar Jan 12 '22 11:01 probil

has someone found a fix for this issue?

hd-luisaguilar avatar Oct 11 '22 20:10 hd-luisaguilar