Conversation
|
Build successful! 🎉 |
|
Build successful! 🎉 |
# Conflicts: # packages/@internationalized/number/src/NumberParser.ts # packages/@internationalized/number/test/NumberParser.test.js
|
Build successful! 🎉 |
|
Build successful! 🎉 |
|
Build successful! 🎉 |
LFDanLu
left a comment
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
interesting case. I'll look into that as follow up
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. |
|
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 |
|
Build successful! 🎉 |
This reverts commit f459439.
|
Build successful! 🎉 |
This reverts commit 6495950.
|
Build successful! 🎉 |
|
Build successful! 🎉 |
|
Build successful! 🎉 |
# Conflicts: # packages/react-aria-components/test/NumberField.test.js
|
Build successful! 🎉 |
LFDanLu
left a comment
There was a problem hiding this comment.
LGTM, reverified that the issues linked are all fixed now and tried a variety of separator/decimal combinations. Might be worthwhile creating a ticket for the followup items just so we don't forget
| value = replaceAll(value, '__DECIMAL__', this.symbols.decimal!); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
what is this doing? this makes me scared. 😂
There was a problem hiding this comment.
These are just temp strings that allow you to swap group and decimal characters, for instance
"1.200,001"
If I try to replace either one immediately, then the number is changed in a way I can't recover
"1.200.001" or "1,200,001"
So I just replace them with the substitution
"1__GROUP__200__DECIMAL__001" so that I can easily fix it to "1,200.001"
Could I do it with one less set of replaces, yes. I am sometimes a little extra explicit for my own reading comprehension. I'll update it.
|
I feel like we're making a lot of assumptions here. How often are people pasting a value that's formatted in a different locale? Looking through the issues above, several of them seem more related to parsing in the wrong locale (e.g. detecting |
|
Build successful! 🎉 |
Sure, I'll do my best. Please note that many of the changes came from running the fuzzing tests compliments of FastCheck. #6861 #5927 was fixed by line 244 #3862 and #7015 were fixed line 237 in tandem with the fix for 5927 #9086 There's more info about my thinking here: #9089 Note, the check for isGroupSymbolAllowed became a combined check with Finally, the other changes in this PR came from #6520 and 9089 where I determined we're making assumptions and things are ambiguous currently. So this PR actually intends to make less assumptions. There are code comments on the other three blocks of code to explain. And then the last block is in support of those three https://github.com/adobe/react-spectrum/pull/8592/changes#diff-983e1f4675c7ada3abd53503639a16a3f999170790ad28dc5b3f9b0ad6ec8731R209 If it would make things better, I can split out some of these into their own PRs. |
|
Build successful! 🎉 |
|
Yeah I'm still a bit concerned about trying to guess what people meant and auto-correct it, e.g. the swapping of group separators and decimals. Someone might be in the middle of editing, blur to go check another tab, come back and what they were doing has re-formatted to a completely different value. Disambiguating this characters is one of the main reasons we use the locale for parsing in the first place. |
|
|
||
| // Replace literals in the parts outside the number | ||
| beforeNumber = beforeNumber.replace(this.symbols.literals, ''); | ||
| afterNumber = afterNumber.replace(this.symbols.literals, ''); |
There was a problem hiding this comment.
When are literals allowed inside the number?
There was a problem hiding this comment.
group separators and decimals may be literals in other locales, very specifically, whitespaces
# Conflicts: # packages/react-aria-components/test/NumberField.test.js
This is already the case, the value could be cleared, reverted to a previous valid value, or formatted as a complete value. |
|
Build successful! 🎉 |
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
But due to concerns, it has been removed #8592 (comment)
Will open a follow up PR that has these changes for further consideration.
✅ Pull Request Checklist:
📝 Test Instructions:
See each bug for reproductions.
🧢 Your Project: