Skip to content

Commit

Permalink
Allow entering decimals into NumberEditCell (#403)
Browse files Browse the repository at this point in the history
* fix: timepicker input

* fix: input props

* feat: number edit cell

* fix: edit cell

* fix: entering decimals

* fix: import
  • Loading branch information
shaynethiessen committed Apr 2, 2024
1 parent 619e7cb commit 84aa0f1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/controls/src/inputs/TableInput/NumberEditCell.tsx
Expand Up @@ -25,21 +25,22 @@ export function NumberEditCell<D extends Record<number, unknown>>(options?: Numb
updateData,
} = props;

const [value, setValue] = useState(initialValue);
const [value, setValue] = useState(initialValue?.toString());

return (
<Input
type="number"
fluid
transparent
{...inputProps}
value={value}
onChange={(ev, v) => {
setValue(v.value ? parseFloat(v.value) : 0);
setValue(v.value);
}}
onBlur={() => {
updateData(index, id, value);
updateData(index, id, parseFloat(value || '0'));
}}
onKeyDown={(event: KeyboardEvent) => addRowOnTab(event, value, props, addRowOnTabIf)}
onKeyDown={(event: KeyboardEvent) => addRowOnTab(event, parseFloat(value), props, addRowOnTabIf)}
/>
);
};
Expand Down

0 comments on commit 84aa0f1

Please sign in to comment.