Skip to content

Commit 453051e

Browse files
committed
Prevent negative values in Est. Yield field
1 parent 62105e1 commit 453051e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/components/KitchenandInventory/GardenManagement/GardenManagement.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ function AddEventModal({ sectionTitle, newEvent, setNewEvent, darkMode, onClose,
192192
step="0.1"
193193
className={`${styles.modalInput} ${dm}`}
194194
value={newEvent.yieldKg}
195-
onChange={e => setNewEvent({ ...newEvent, yieldKg: e.target.value })}
195+
onChange={e => {
196+
if (e.target.value === '' || Number(e.target.value) >= 0) {
197+
setNewEvent({ ...newEvent, yieldKg: e.target.value });
198+
}
199+
}}
196200
placeholder="e.g. 40"
197201
/>
198202

0 commit comments

Comments
 (0)