adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
13.08k stars 1.14k forks source link

NumberParser: Incorrect Parsing of Comma-Separated Number Strings #7420

Open tihcamos opened 4 days ago

tihcamos commented 4 days ago

Provide a general summary of the issue here

When using the NumberParser from @internationalized/number, I encountered an issue where the string '1,1,1.2' is being parsed incorrectly as 111.2.

๐Ÿค” Expected Behavior?

The input string '1,1,1.2' should throw a parsing error (since it is not a valid number format in any locale),

๐Ÿ˜ฏ Current Behavior

The input string '1,1,1.2' is parsed as 111.2, which appears to ignore the commas inappropriately and concatenate the numbers.

๐Ÿ’ Possible Solution

No response

๐Ÿ”ฆ Context

No response

๐Ÿ–ฅ๏ธ Steps to Reproduce

  1. Import and initialize NumberParser:

    import { NumberParser } from '@internationalized/number';
    
    const parser = new NumberParser('en-US'); // Example locale
    const result = parser.parse('1,1,1.2');
    console.log(result); // Outputs: 111.2
  2. Observe that the output is 111.2 instead of an error or a correctly parsed value.

Version

3.5.4

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

Windows 11

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response