Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy/paste doesn't work correctly with format de #2166

Closed
jeanmarc78 opened this issue Feb 17, 2015 · 12 comments
Closed

copy/paste doesn't work correctly with format de #2166

jeanmarc78 opened this issue Feb 17, 2015 · 12 comments

Comments

@jeanmarc78
Copy link

Hi,
I reproduce the problem on http://handsontable.com/demo/numeric.html
on the column (Price (€)) and the row Mercedes A160, i type 22,10,
i click enter then have the correct value 22,10 €.
if i copy this cell (ctrl + c) an i paste (ctrl+v) for the row "Citroen C4 Coupe"
and the column (Price (€)) i have the wrong value 221,00€

if i use the fill vertical action, i have the correct value
if i enter another value like 22,11 it works .

regards
jean marc

@jeanmarc78
Copy link
Author

i fix the issue in handsontable.full.js for the function function validateChanges(changes, source, callback).

i replace
// this input in format XXXX.XX is likely to come from paste. Let's parse it using international rules
else if (changes[i][3]===len - 3 && changes[i][3].indexOf(",") === -1) {

with
// this input in format XXXX.XX is likely to come from paste. Let's parse it using international rules
else if (changes[i][3].indexOf(".") != -1 && changes[i][3].indexOf(",") === -1) {

@jeanmarc78
Copy link
Author

i continue my private discussion,
i found a better workaround , i think

i add if (cellProperties.language == 'de')
{
changes[i][3]=changes[i][3].replace('.',',');
changes[i][3]=changes[i][3].replace(' ','');
}
for the function

function validateChanges(changes, source, callback) {
var waitingForValidator = new ValidatorsQueue();
waitingForValidator.onQueueEmpty = resolve;

for (var i = changes.length - 1; i >= 0; i--) {
  if (changes[i] === null) {
    changes.splice(i, 1);
  }
  else {
    var row = changes[i][0];
    var col = datamap.propToCol(changes[i][1]);
    // column order may have changes, so we need to translate physical col index (stored in datasource) to logical (displayed to user)
    var logicalCol = instance.runHooks('modifyCol', col);
    var cellProperties = instance.getCellMeta(row, logicalCol);

    if (cellProperties.type === 'numeric' && typeof changes[i][3] === 'string') {
      if (changes[i][3].length > 0 && (/^-?[\d\s]*(\.|\,)?\d*$/.test(changes[i][3]) || cellProperties.format )) {
        var len = changes[i][3].length;

        if (cellProperties.language == 'de')
        {
           changes[i][3]=changes[i][3].replace('.',',');
           changes[i][3]=changes[i][3].replace(' ','');
        }

@krzysztofspilka
Copy link
Member

Hi @jeanmarc78, let me just mark this issue to be checked later. Thanks for reporting!

@ereboucas
Copy link

@jeanmarc78 thanks for your workaround. I applied it on 0.11.4 and worked like a charm.

@AMBudnik
Copy link
Contributor

AMBudnik commented Apr 8, 2015

Confirmed. When you:

  1. type as @jeanmarc78 described (on the column (Price (€)) and the row Mercedes A160, i type 22,10,)
  2. edit other cell (no matter which)
  3. click enter on our 22,10€ cell
  4. 22,10€ cell becomes 221,00€

@jeanmarc78
Copy link
Author

hello,
is it possible to increase the bug priority ?
because each time a new release is out,
i have to put the workaround.

best regards
jm

@krzysztofspilka
Copy link
Member

@jeanmarc78 will do. Just added to the milestone 0.18.1 so we don't loose it from our sight.

@krzysztofspilka krzysztofspilka removed this from the 0.24.2 milestone Apr 7, 2016
@krzysztofspilka krzysztofspilka modified the milestones: 0.24.3, 0.24.4 Apr 28, 2016
@AMBudnik
Copy link
Contributor

Still reproducible in 0.26.0 (switched to numbro)

@ClaudineiFernandes
Copy link

still reproducible in https://docs.handsontable.com/pro/1.5.0/demo-numeric.html

@AMBudnik
Copy link
Contributor

AMBudnik commented Oct 13, 2016

@jeanmarc78 @ClaudineiFernandes
This bug was tracking us like a shadow on every update and finally we fixed it. I hope it works fine in your projects as well. If you could find a moment to test it I would be more than happy.

Thanks in advance!

@AMBudnik
Copy link
Contributor

After more testing I guess that this implementation solved our issue.
Glad it's working fine, thanks @swistach

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

No branches or pull requests

7 participants