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: number formatting does not update when locale is set through PrimeReactContext #6584

Closed
codalf opened this issue May 7, 2024 · 1 comment · Fixed by #6586, leoo1992/GeradorQRCode#40, mtech-31-quemistry/quemistry_client_web#3 or leoo1992/GeradorQRCode#57 · May be fixed by nhattpn/BTL_LTNC#56
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@codalf
Copy link

codalf commented May 7, 2024

Describe the bug

When the current locale is updated using PrimeReactContext, it is not properly picked up by InputNumber. Moreover, after changing the locale, seemingly arbitrary input is added when editing the field content.

The problem could be that in InputNumber.js in line 1136 (https://github.com/primefaces/primereact/blob/master/components/lib/inputnumber/InputNumber.js#L1136), the parser is reconstructed only when props.locale changes, but not when _locale changes, which is derived from the locale set in PrimeReactContext.

Reproducer

https://stackblitz.com/edit/rkhk7w?file=src%2FApp.jsx

PrimeReact version

10.5.1

React version

18.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

Chrome 124, Firefox 125

Steps to reproduce the behavior

  1. Start reproducer
  2. Click on 'German' => Number formatting is not updated
  3. Edit number (enter numbers or delete numbers) => content is screwed up

Expected behavior

  1. Number formatting should update according to locale
  2. Number input should display what is entered
@codalf codalf added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label May 7, 2024
@Rekl0w
Copy link
Contributor

Rekl0w commented May 7, 2024

PR submitted.

@melloware melloware added Type: Bug Issue contains a defect related to a specific component. 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 7, 2024
@melloware melloware added this to the 10.7.0 milestone May 7, 2024
melloware pushed a commit that referenced this issue May 7, 2024
* Fix #6584: _locale fix

* Revert "Fix #6584: _locale fix"

This reverts commit aea83a4.

* Fix #6584: _locale fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment