From 01cab161ffc7c7aa2226c54773a57fc3671ba388 Mon Sep 17 00:00:00 2001 From: Hannes Limmer Date: Fri, 23 Feb 2024 17:50:13 +0100 Subject: [PATCH 1/3] removed unused --- src/app/components/inputnumber/inputnumber.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/app/components/inputnumber/inputnumber.ts b/src/app/components/inputnumber/inputnumber.ts index df35268c29b..5cd4ee7077f 100644 --- a/src/app/components/inputnumber/inputnumber.ts +++ b/src/app/components/inputnumber/inputnumber.ts @@ -1417,10 +1417,6 @@ export class InputNumber implements OnInit, AfterContentInit, OnChanges, Control clearInterval(this.timer); } } - - getFormatter() { - return this.numberFormat; - } } @NgModule({ From 82a4050b6cc5a5891e6ba177a0f0d9143c8bb635 Mon Sep 17 00:00:00 2001 From: Hannes Limmer Date: Fri, 23 Feb 2024 19:34:14 +0100 Subject: [PATCH 2/3] fixed left arrow Key --- src/app/components/inputnumber/inputnumber.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/components/inputnumber/inputnumber.ts b/src/app/components/inputnumber/inputnumber.ts index 5cd4ee7077f..e4ce0841ea9 100644 --- a/src/app/components/inputnumber/inputnumber.ts +++ b/src/app/components/inputnumber/inputnumber.ts @@ -444,7 +444,7 @@ export class InputNumber implements OnInit, AfterContentInit, OnChanges, Control */ @Output() onClear: EventEmitter = new EventEmitter(); - @ViewChild('input') input!: ElementRef; + @ViewChild('input') input!: ElementRef; @ContentChildren(PrimeTemplate) templates!: QueryList; @@ -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; @@ -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); From a37598e8ebefb6080c092bc9c42ca40df44211f1 Mon Sep 17 00:00:00 2001 From: Hannes Limmer Date: Fri, 23 Feb 2024 19:43:39 +0100 Subject: [PATCH 3/3] fixed right key --- src/app/components/inputnumber/inputnumber.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/components/inputnumber/inputnumber.ts b/src/app/components/inputnumber/inputnumber.ts index e4ce0841ea9..46bca23dc44 100644 --- a/src/app/components/inputnumber/inputnumber.ts +++ b/src/app/components/inputnumber/inputnumber.ts @@ -825,7 +825,8 @@ 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; } @@ -833,8 +834,11 @@ export class InputNumber implements OnInit, AfterContentInit, OnChanges, Control 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;