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

Cursor should move at the end when "Zero" #135

Open
FractalMind opened this issue Aug 26, 2021 · 0 comments
Open

Cursor should move at the end when "Zero" #135

FractalMind opened this issue Aug 26, 2021 · 0 comments

Comments

@FractalMind
Copy link

When "CAD $0.00"
People usually click after the $ to INSERT numbers.

The default behavior is after entering 99 is:

990.00 which is wrong because it ADDS numbers when it should INSERT like:
0.99 Because it moved the cursor to the end.

Here's my quick fix
angular 8, ionic 4

  @ViewChild('inputField', {static: true}) inputField: ElementRef;
   ...
  onClickInput() {
    // tslint:disable-next-line:triple-equals
     if (this.value == 0) {
       // tslint:disable-next-line:triple-equals
         if (typeof this.inputField.nativeElement.selectionStart == 'number') {
           this.inputField.nativeElement.selectionStart = this.inputField.nativeElement.selectionEnd = 
           this.inputField.nativeElement.value.length;
           // tslint:disable-next-line:triple-equals
         } else if (typeof this.inputField.nativeElement.createTextRange != 'undefined') {
           this.inputField.nativeElement.focus();
           let range = this.inputField.nativeElement.createTextRange();
           range.collapse(false);
           range.select();
         }
     }
  }
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