Skip to content

Commit

Permalink
fixed right key
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes Limmer committed Feb 23, 2024
1 parent 82a4050 commit a37598e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/app/components/inputnumber/inputnumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,16 +825,20 @@ export class InputNumber implements OnInit, AfterContentInit, OnChanges, Control

case 'ArrowLeft':
for( let index=selectionStart; index<=inputValue.length;index++){
if(this.isNumeralChar(inputValue.charAt(index===0?0:index-1))){
const previousCharIndex = index === 0 ? 0 : index - 1;
if(this.isNumeralChar(inputValue.charAt(previousCharIndex))){
this.input.nativeElement.setSelectionRange(index, index);
break;
}
}
break;

case 'ArrowRight':
if (!this.isNumeralChar(inputValue.charAt(selectionStart))) {
event.preventDefault();
for( let index=selectionEnd; index>=0;index--){
if(this.isNumeralChar(inputValue.charAt(index))){
this.input.nativeElement.setSelectionRange(index, index);
break;
}
}
break;

Expand Down

0 comments on commit a37598e

Please sign in to comment.