primeng icon indicating copy to clipboard operation
primeng copied to clipboard

InputNumber Component: Default value for minFractionDigits is not correct when value explicitly set to null

Open timandella opened this issue 1 year ago • 0 comments

Describe the bug

When an inputNumber control is used, with the minFractionDigits attributes explicitly set to null, then the default value used by the control is 0. This is contrary to what is described in the documentation (https://primeng.org/inputnumber#api.inputnumber.props.minFractionDigits), where it says "the default for currency formatting is the number of minor unit digits provided by the ISO 4217 currency code list", which should be 2 in this case

For example, the html being used is this:

    <p-inputNumber
      [(ngModel)]="value2"
      inputId="id2"
      mode="currency"
      currency="GBP"
      locale="en-GB"
      [minFractionDigits]="minFractionDigits"
      [maxFractionDigits]="maxFractionDigits"
    >

In the angular component, the relevant properties are set as follows:

public minFractionDigits?: number | null = null;
public maxFractionDigits?: number | null = null;

In this case, no fractional digits are shown

If the html is changed to remove the two properties altogether, then it works as expected. However "null" is meant to be the default value, and so you would expect it to work when the properties are set to this

Issue occurs in PrimeNg 17.12.0 but not in 17.14.1 (17.13.0 had another issue where the fields became readonly in this instance)

Environment

Windows 10

Reproducer

https://stackblitz.com/edit/w7v6fx?file=src%2Fapp%2Fdemo%2Finput-number-currency-demo.html

Angular version

17.3.1

PrimeNG version

17.14.1

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.19.0

Browser(s)

Edge

Steps to reproduce the behavior

  1. Use a p-inputNumber component where the minFractionDigits and maxFractionDigits are explicitly set to null
  2. Enter a value

Expected behavior

Default should be 2 minimum fraction digits

timandella avatar Apr 24 '24 08:04 timandella