Skip to content

Commit

Permalink
[STUD-349, MRKT-161]: numeric input fixes (#740)
Browse files Browse the repository at this point in the history
* updates numeric input functionality

* adds placeholder to sale input
  • Loading branch information
scandycuz authored Oct 10, 2024
1 parent 8a67bcb commit 7254ef3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion apps/marketplace/src/components/Sale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,11 @@ const Sale: FunctionComponent<SaleProps> = ({
</Typography>
<Stack direction={ "row" }>
<Box maxWidth={ "150px" }>
<TextInputField name="streamTokens" type="number" />
<TextInputField
name="streamTokens"
placeholder="0"
type="number"
/>
</Box>
<Typography
alignSelf="center"
Expand Down
10 changes: 6 additions & 4 deletions packages/elements/src/lib/NumericInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ export const NumericInput: ForwardRefRenderFunction<
*/
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
if (onChange) {
const formattedValue = event.target.value.replace(/,/g, "");
const numberValue = Number(formattedValue);
const value = event.target.value;
const numberValue = value ? Number(value.replace(/,/g, "")) : null;

event.target.type = "number";
event.target.valueAsNumber = numberValue;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const newTarget = event.target as any;
newTarget.value = numberValue;
event.target = newTarget;

onChange(event);
}
Expand Down

0 comments on commit 7254ef3

Please sign in to comment.