Skip to content

Conversation

@snowystinger
Copy link
Member

@snowystinger snowystinger commented Jul 21, 2025

Closes #7015, Closes #3862, Closes #6861, Closes #5927, Closes #9086

Finally had some thoughts on how to address some of the issues that were being tackled in #6520

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Try pasting numbers with group/decimal characters that are opposite of what the current formatting expects. Note, this is an improvement, there are some cases we can reasonably handle, then there are those which are still ambiguous.

For example, if there are two symbols in use, one is before the other, it's reasonable to assume that the first one is group and the second is decimal.
Or if there are multiple of one symbol, but only one of the other, then it's reasonable to assume that the symbol with multiple instances is the group, and the symbol with only one instance is the decimal.

On the other side, ambiguous cases are if there is only one symbol in use, we cannot reasonably know if it's a partial number with a group separator vs a decimal symbol. At least, I have determined a good way to figure this one out.

One other note, this does not extend to units/currency symbols. Those are literal and should not be fuzzy matched/removed. For example, pasting €10 into a currency formatted numberfield should not become $10 just because the formatting is for USD. They are not equivalent.

While this PR closes 9086, it just matches other locales to the current behaviour of en-US.

🧢 Your Project:

@rspbot
Copy link

rspbot commented Jul 21, 2025

@rspbot
Copy link

rspbot commented Jul 21, 2025

# Conflicts:
#	packages/@internationalized/number/src/NumberParser.ts
#	packages/@internationalized/number/test/NumberParser.test.js
@rspbot
Copy link

rspbot commented Aug 22, 2025

@rspbot
Copy link

rspbot commented Aug 27, 2025

@rspbot
Copy link

rspbot commented Sep 11, 2025

LFDanLu
LFDanLu previously approved these changes Sep 17, 2025
Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified that this fixes the linked issues and the updates to the parser logic make sense. Perhaps a bit silly of a case, but what would we expect if someone types "123, 456"? It has the group separator and a non matching symbol from a different format and thus resolves to "123.456" since the space becomes the decimal separator but perhaps someone could expect it to resolve to "123,456"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified the fix for #6861 here, but noticed that I can't go into the negatives it seems? It seems to cycle between what I think is 1 and 0.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting case. I'll look into that as follow up

@snowystinger
Copy link
Member Author

Verified that this fixes the linked issues and the updates to the parser logic make sense. Perhaps a bit silly of a case, but what would we expect if someone types "123, 456"? It has the group separator and a non matching symbol from a different format and thus resolves to "123.456" since the space becomes the decimal separator but perhaps someone could expect it to resolve to "123,456"

Good question, that is a little ambiguous, think I should fail to parse it instead? I could limit the failure to parse case to no numbers between the two symbols.

@LFDanLu
Copy link
Member

LFDanLu commented Sep 18, 2025

Yeah I think maybe err on the side of caution and fail to parse it if there aren't any numbers between the two symbols

@rspbot
Copy link

rspbot commented Oct 26, 2025

@rspbot
Copy link

rspbot commented Oct 26, 2025

await user.paste('1,024');
await user.tab();
expect(input).toHaveAttribute('value', '');
// TODO: both of the above should parse to 1024
Copy link
Member Author

@snowystinger snowystinger Oct 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Note: For this PR at least current handling in other locales will now behave the same as en-US
// But we should fix this in a follow up

@rspbot
Copy link

rspbot commented Oct 26, 2025

@rspbot
Copy link

rspbot commented Oct 28, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

4 participants