Skip to content

Commit

Permalink
refactor: 💡 [Input Number] added a feature
Browse files Browse the repository at this point in the history
✅ Closes: #316
  • Loading branch information
CrisGrud committed Aug 25, 2023
1 parent 2e2d3f9 commit eccab4f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/components/InputNumber/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ const InputNumber: FC<IInputNumber> = ({
if (isNaN(numericValue)) {
return null;
}
const minValueString = minValue.toString();
if (minValueString.length > value.length) {
if (minValue > numericValue) {
return numericValue;
}

Expand Down Expand Up @@ -84,13 +83,15 @@ const InputNumber: FC<IInputNumber> = ({
[getNumericValue, onChange]
);

const OnKeyDownHandler = useCallback((e: React.KeyboardEvent) => {
if (e.key === "e" || e.key === "E" || e.key === "-" || e.key === "+") {
e.preventDefault();
}
}, []);

return (
<MUITextField
onKeyDown={(e) => {
if (e.key === "e" || e.key === "E" || e.key === "-" || e.key === "+") {
e.preventDefault();
}
}}
onKeyDown={OnKeyDownHandler}
disabled={disabled}
InputLabelProps={{
shrink,
Expand Down

0 comments on commit eccab4f

Please sign in to comment.