- fixed NaN value is given fo rundefined input values;

This commit is contained in:
Vitalii Kiiko
2025-01-08 15:56:18 +01:00
parent 68f6152e6f
commit dc9f4d566d
3 changed files with 11 additions and 1 deletions

View File

@@ -6,12 +6,17 @@ const DefaultCell = ({ getValue, row: { index }, column: { id }, table }) => {
table.options.meta?.updateData(index, id, e.target.value);
};
const onFocus = (e) => {
e.target.select();
}
return (
<input
disabled={disabled}
value={initialValue ?? ''}
onChange={(e) => table.options.meta?.updateData(index, id, e.target.value)}
onBlur={onBlur}
onFocus={onFocus}
className="w-full px-2 py-1 border rounded"
/>
);

View File

@@ -6,7 +6,7 @@ const LastRowCell = ({columnId, lastRows, columnMeta = {}, getColumnDataFn}) =>
if (columnMeta.enableFormula) {
const getAllRowsValues = getColumnDataFn(columnId)
.map(v => isEmpty(v) ? 0 : v);
.map(v => isEmpty(v) || isNil(v) ? 0 : v);
if (cellValue === 'sum') {
cellValue = sum(getAllRowsValues);

View File

@@ -7,6 +7,10 @@ const NumericFormulaCell = ({ getValue, row: { index }, column: { id }, table })
table.options.meta?.updateData(index, id, numValue);
};
const onFocus = (e) => {
e.target.select();
}
const onChange = (e) => {
if (e.target.value === 0 || !isNaN(e.target.value)) {
table.options.meta?.updateData(index, id, e.target.value);
@@ -19,6 +23,7 @@ const NumericFormulaCell = ({ getValue, row: { index }, column: { id }, table })
disabled={disabled}
value={initialValue ?? 0}
onChange={onChange}
onFocus={onFocus}
onBlur={onBlur}
step="any"
className="w-full px-2 py-1 border rounded"