nick-keller / react-datasheet-grid

An Airtable-like / Excel-like component to create beautiful spreadsheets.
MIT License
1.81k stars 170 forks source link

Fix internationalization on user input #249

Closed alpharaoh closed 1 year ago

alpharaoh commented 1 year ago

Internationalization of user input doesn't work, users must type only in the format that parseFloat accepts which is the standard English thousand (,) and decimal (.) separators.

An example of what goes wrong:

German user sees table values respecting the separation system (i.e thousand separator in . and decimal seperator in ,). This is good, but then he types in a new value 5.000,5 (five thousand point five), but parseFloat will return 5!

This is confusing since the table displays the values in the correct form, but you must type in values using the standard English form.

netlify[bot] commented 1 year ago

Deploy Preview for react-datasheet-grid canceled.

Name Link
Latest commit 0be4666c92a37b324394c56683861966b4bea3df
Latest deploy log https://app.netlify.com/sites/react-datasheet-grid/deploys/63d926d353eb680009b3d07b
nick-keller commented 1 year ago

First: thansk a lot for your help @alpharaoh! This topic is an endless source of discussion, and your solution is just one in many. There is no right answer here, some will argue that you should always type in the parseFloat format because the decimal point in handy on the keyboard, others will say you need to support both, which brings even more questions to the table...

Long story short, I believe it is not the goal of this library to solve this issue, it merly provides a simple implementation using parseFloat and lets you use you own very simply as demonstrated by this PR. Everything that can be done outside of this library should be done outside. You could perhaps create another package, dsg-number-columns for instance, that provides implementation for many other column types that you can comeup with, but making the core library bigger is not a direction I want to go in.