Skip to content

Commit 28e8b10

Browse files
author
Michael Jordan
committed
fix(#4967): parse leading ambiguous decimal symbol as a decimal
Addresses #6520 (comment)
1 parent a29926f commit 28e8b10

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

packages/@internationalized/number/src/NumberParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ class NumberParserImpl {
311311
decimalPartMatches?.groups?.digits?.length < 3 ||
312312
decimalPartMatches?.groups?.digits?.length > 3 ||
313313
integerPart.length > 3 ||
314+
(integerPart.length === 0 && decimalPartMatches?.groups?.digits?.length === 3) ||
314315
(integerPart === '0' || integerPart === '\u0660' || integerPart === '\u3007')
315316
)
316317
) {

packages/@internationalized/number/test/NumberParser.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ describe('NumberParser', function () {
343343

344344
it('should support group characters', function () {
345345
expect(new NumberParser('en-US', {style: 'decimal'}).isValidPartialNumber(',')).toBe(true); // en-US-u-nu-arab uses commas as the decimal point character
346-
expect(new NumberParser('en-US', {style: 'decimal'}).isValidPartialNumber(',000')).toBe(false); // latin numerals cannot follow arab decimal point
346+
expect(new NumberParser('en-US', {style: 'decimal'}).isValidPartialNumber(',000')).toBe(true); // latin numerals cannot follow arab decimal point, but parser will interpret a comma as a decimal point and interpret this as 0.
347347
expect(new NumberParser('en-US', {style: 'decimal'}).isValidPartialNumber('1,000')).toBe(true);
348348
expect(new NumberParser('en-US', {style: 'decimal'}).isValidPartialNumber('-1,000')).toBe(true);
349349
expect(new NumberParser('en-US', {style: 'decimal'}).isValidPartialNumber('1,000,000')).toBe(true);

0 commit comments

Comments
 (0)