From 103b1c6b704bd22b8fae3e6605b4cc2be8b60036 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Sat, 14 Oct 2023 14:30:44 +1100 Subject: [PATCH] refactor(web/InventoryControl): floor input value and set minimum --- web/src/components/inventory/InventoryControl.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/web/src/components/inventory/InventoryControl.tsx b/web/src/components/inventory/InventoryControl.tsx index 4aa080a17b..8b4cfff424 100644 --- a/web/src/components/inventory/InventoryControl.tsx +++ b/web/src/components/inventory/InventoryControl.tsx @@ -30,8 +30,8 @@ const InventoryControl: React.FC = () => { })); const inputHandler = (event: React.ChangeEvent) => { - if (event.target.valueAsNumber % 1 !== 0 || isNaN(event.target.valueAsNumber) || event.target.valueAsNumber < 0) - event.target.valueAsNumber = 0; + event.target.valueAsNumber = + isNaN(event.target.valueAsNumber) || event.target.valueAsNumber < 0 ? 0 : Math.floor(event.target.valueAsNumber); dispatch(setItemAmount(event.target.valueAsNumber)); }; @@ -40,7 +40,13 @@ const InventoryControl: React.FC = () => {
- +