primeng icon indicating copy to clipboard operation
primeng copied to clipboard

inputnumber : not able to type "."(dot) or comma"with"(respective locale) for decimal point. Need to move the cursor manually to enter digit after decimal point

Open priyanhsu10 opened this issue 6 years ago • 9 comments

ngular version: 9.1.1 PrimeNG version: 9.1.0

snapshot image

User is getting frustrated due to to this.

priyanhsu10 avatar Jun 28 '20 05:06 priyanhsu10

Got the same issue with v9.1.0 and Angular 9.1.8... Also happens with the components on the showcase page of the inputNumber

franciscoghansen avatar Jun 29 '20 12:06 franciscoghansen

OMG this is so infuriating. Another problem is that for example in showcase page when you select whole "Currency -> United States" value and input something like "1" it puts "$1,00" and cursor moves to the end of input and you are unable to write... ok I am switching to ngx-mask for now.

Celebes avatar Aug 06 '20 08:08 Celebes

Thanks a lot for your feedbacks! Could you please test these issues on PrimeReact inputNumber? https://primefaces.org/primereact/showcase/#/inputnumber if it works fine for you, I can add new improvements to PrimeNg. This component is open to user experiences. Therefore, feedback is important to us.

Thanks again! Best Regards,

mertsincan avatar Aug 21 '20 14:08 mertsincan

Hello. On PrimeReact inputNumber the behaviour is better, but still weird.

I'm testing on Windows with Chrome.

For example, if you tab focus from United States to Germany and try to type a number like 123,00 the first keystroke works and move the cursor to the end, after the € symbol.

The same happens on United States if you position the cursor at the end and select all with Shift+Home. Trying to type a number like 123,00 happens to work only for the first algarism.

vstiebe avatar Aug 21 '20 17:08 vstiebe

Fixed in https://github.com/primefaces/primeng/commit/1258ca4d4b7a15575fa950fc83af980f2107d3d5

Similar issue; https://github.com/primefaces/primeng/issues/8900

Thanks a lot for the feedbacks, Best Regards,

mertsincan avatar Sep 01 '20 11:09 mertsincan

This still seems to be an issue.

I'm using version 11.3.1 and if I try to type a decimal in an input, it doesn't allow me to type the decimal separator. The workaround I've found is setting minFractionDigits to 1 but you'd expect an input in decimal mode to allow you to actually type decimals into it regardless of the minimum fraction digits.

Example code: <p-inputNumber mode="decimal" max="100" [step]="2.5" suffix="%">

JordanMunroe avatar Apr 24 '21 18:04 JordanMunroe

I'm having this issue with PrimeNG 11.4.2

TekTimmy avatar Oct 19 '21 19:10 TekTimmy

I had the same issue, I fixed it by the following way:

First, I used the ViewChild() method to access through the input element:

@ViewChild('inputReference', { read : ElementRef }) inputElement: ElementRef;

And then, I wrote some logic to handle when the input was or not focused. With that in mind, I used a host listener to handle commas key pressed and update the input value:

  @HostListener('keydown', ['$event.key'])
  onKeyDown(key: string) {
    if(
      this.isControlFocused 
      && key === ','
      && this.inputElement.nativeElement.firstChild.childNodes[0].value.indexOf(',') === -1) {
      this.inputElement.nativeElement.firstChild.childNodes[0].value += ',';
    }

nhussein11 avatar Dec 14 '22 16:12 nhussein11

Hi everyone,

I am working on version 17.12.0, and it did not let me use decimal punctuation marks even though I selected the decimal mode. As @JordanMunroe said, the problem lies in how min and max are treated when entering a decimal number. Since I don't want to force my user always to enter decimal numbers I have found this way to enable the decimal '.' using [minFractionDigits] and [maxFractionDigits].

<p-inputNumber class="text-center" formControlName="weighting" mode="decimal" [size]="7" [maxlength]="6" [step]="0.1" inputId="weighting" [minFractionDigits]="0" [maxFractionDigits]="3" [min]="0.00" [max]="100.00" />

It could be useful to someone, or I'm giving it a lot of thought and it seems easier than it is. Regards!

MigeruDev avatar Sep 11 '24 18:09 MigeruDev