Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
timandella opened this issue Apr 24, 2024 · 0 comments · Fixed by #15660
Labels
LTS-PORTABLE Issue's fix will be ported to supported LTS versions Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@timandella
Copy link

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 timandella added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 24, 2024
@mehmetcetin01140 mehmetcetin01140 added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels May 20, 2024
@mehmetcetin01140 mehmetcetin01140 added this to the 17.17.2 milestone May 20, 2024
@cetincakiroglu cetincakiroglu modified the milestones: 17.17.2, 17.18.0 May 29, 2024
@cetincakiroglu cetincakiroglu added the LTS-PORTABLE Issue's fix will be ported to supported LTS versions label May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTS-PORTABLE Issue's fix will be ported to supported LTS versions Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
3 participants