Describe the bug
Datagrid: Palaceholder sets to NaN.000 after clicking in the empty field
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Placeholder should show
Version
4.530 - beta - IDS
Screenshots
Platform
All major browsers & OS
Additional context
N/a
@Jah25 Maybe should have pointed you in the right place as datagrid is a bit crazy. But i think the problem is that we are using:
formatter: placeholder and editor:input on numbers here:
https://github.com/infor-design/enterprise/blob/main/app/views/components/datagrid/example-placeholder.html#L71
Since this is a first issue i think its maybe a little complex to start with (sorry on my part). But i can see a fix which would be in https://github.com/infor-design/enterprise/blob/main/src/components/datagrid/datagrid.js#L10434
The coerveValue function is trying to put the data back in the source format fx (number in this case). I think it would be safe to exclude NaN here. So maybe NaN it just shows blank
// coerced value may be coerced to empty string, null, or 0
if (coercedVal === undefined && Number.isNaN(value)) {
coercedVal = value;
}
Something along those lines. But just a hint. Im noticing this example is a little odd as well so maybe we just fix this quick and move on.
HTH
@tmcconechy Hey Tim I just saw this. Yeah it took a little chasing to find it but I also found the coercion was the issue though I ran across it here where the coercion is checking against the oldValue to determine the datatype it should force too
https://github.com/infor-design/enterprise/blob/main/src/components/datagrid/datagrid.js#L10372
my fix was going to be something like this
let isWord = /[A-Za-z!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]]/
...
else if (typeof oldVal === 'number' && value && isWord.test(value) ) {
newVal = Locale.parseNumber(value); // remove thousands sep , keep a number a number
}
I don't think it's perfect protection but it covers a few more edge cases, do you want to move forward with a change or the example fix?
@Jah25 that sounds like it should work. Lets give it a try