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

Component: InputNumber maxlength and maxFractionDigits attributes are ignored by pasting #13588

Closed
avytak opened this issue Aug 31, 2023 · 2 comments · Fixed by #13594
Closed
Labels
LTS-PORTABLE Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@avytak
Copy link

avytak commented Aug 31, 2023

Describe the bug

When we set the maxlength and maxFractionDigits attributes for the inputNumber:
[maxlength]="5" [maxFractionDigits]="2"
If we type the characters, then the field will accept 5 characters which is expected. The field accepts more than 5 characters when we paste the value into the blank field (for example 1234567899)

A possible workaround could be adding the max attribute (in that case 99999) but it will still accept the 99998.9999 (as example)

Environment

Mac OS

Reproducer

https://stackblitz.com/edit/stackblitz-starters-kp6rdr?file=src%2Fmain.ts

Angular version

14.2.0 and 16.2.3

PrimeNG version

14.2.2 and 16.3.1

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.16.0

Browser(s)

Chrome 116.0.5845.110

Steps to reproduce the behavior

  1. Copy 1234567899
  2. Paste it in the test input
  3. See that the field accepted 10 characters
  4. Set the max attribute to 99999
  5. Try to paste the same number
  6. See that after the blur it is 99999 now
  7. Try to paste 99998.9999
  8. See that the field accepted 4 characters after the dot (.)

Expected behavior

Input should slice the value according to the max length and maxFractionDigits attributes after the paste or after the blur

@avytak avytak added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Aug 31, 2023
@avytak
Copy link
Author

avytak commented Aug 31, 2023

It would be nice if you added a fix to 14.2.2 version as well.

dylansyoung added a commit to dylansyoung/primeng that referenced this issue Aug 31, 2023
dylansyoung added a commit to dylansyoung/primeng that referenced this issue Aug 31, 2023
dylansyoung added a commit to dylansyoung/primeng that referenced this issue Aug 31, 2023
@mertsincan mertsincan 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 Sep 2, 2023
@mertsincan mertsincan added this to the 16.3.2 milestone Sep 2, 2023
@mertsincan mertsincan linked a pull request Sep 2, 2023 that will close this issue
@jasonverber
Copy link
Contributor

I think the fix is truncating in the wrong place, i.e. it will fix the issue if you try to paste in more than the maxlength all at once but it doesn't prevent repeatedly pasting in fewer digits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTS-PORTABLE Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants