Skip to content

Commit

Permalink
fixed left arrow Key
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes Limmer committed Feb 23, 2024
1 parent 01cab16 commit 82a4050
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/app/components/inputnumber/inputnumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ export class InputNumber implements OnInit, AfterContentInit, OnChanges, Control
*/
@Output() onClear: EventEmitter<void> = new EventEmitter<void>();

@ViewChild('input') input!: ElementRef;
@ViewChild('input') input!: ElementRef<HTMLInputElement>;

@ContentChildren(PrimeTemplate) templates!: QueryList<PrimeTemplate>;

Expand Down Expand Up @@ -824,8 +824,11 @@ export class InputNumber implements OnInit, AfterContentInit, OnChanges, Control
break;

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

Expand Down Expand Up @@ -1363,7 +1366,7 @@ export class InputNumber implements OnInit, AfterContentInit, OnChanges, Control
onInputBlur(event: Event) {
this.focused = false;

let newValue = this.validateValue(this.parseValue(this.input.nativeElement.value));
let newValue = this.validateValue(this.parseValue(this.input.nativeElement.value)).toString();
this.input.nativeElement.value = this.formatValue(newValue);
this.input.nativeElement.setAttribute('aria-valuenow', newValue);
this.updateModel(event, newValue);
Expand Down

0 comments on commit 82a4050

Please sign in to comment.