Repository navigation
Bugfix/fix numeric field input - #88
Conversation
- Updated `PathGenerationOptions` to use local state for number inputs, improving user experience by allowing direct input without native steppers. - Added validation for numeric inputs in `PesticidePrescriptionsView`, ensuring all thresholds are valid before enabling the save button. - Refactored `UploadSettingsModal` to manage drafts for input fields, implementing validation checks for various settings to ensure correct values are provided. - Updated CSS to remove native number steppers for a cleaner input experience.
- Deleted `dockereqs.txt`, which contained outdated Docker requirements for various components. - Removed empty README files from `code`, `data`, and `tests` directories, streamlining the project structure. - Cleaned up `useful_commands.txt` by removing unnecessary commands related to Docker image builds and runs.
- Revised the guidance in the UploadSettingsModal to emphasize the importance of using default NodeODM settings, highlighting potential quality issues with custom settings.
There was a problem hiding this comment.
Pull request overview
Fixes frontend numeric input UX so users can type/edit numbers without immediate coercion (which can introduce unwanted leading/default 0 values), and adds basic validation/guardrails before saving.
Changes:
- Introduce “draft string” state for several numeric inputs (to avoid forced numeric coercion while typing) and add form validation + disabled Save behavior.
- Add validation gating for spray threshold edits in the prescription thresholds modal.
- Remove native number steppers globally via CSS.
Reviewed changes
Copilot reviewed 6 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
dockereqs.txt |
Removes the existing Docker requirements content (file deletion). |
code/frontend/src/index.css |
Removes native number steppers for <input type="number">. |
code/frontend/src/components/UploadSettingsModal.tsx |
Switches many numeric settings fields to draft-string inputs + validates before enabling Save. |
code/frontend/src/components/PesticidePrescriptionsView.tsx |
Adds parsing/validation for spray threshold drafts and disables Save when invalid. |
code/frontend/src/components/PathGenerationOptions.tsx |
Uses draft-string inputs for numeric path generation options to avoid coercion while typing. |
code/backend/useful_commands.txt |
Trims/rewrites developer command notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const parsedDraftGpaNone = draftGpaNone.trim() === '' ? Number.NaN : Number.parseFloat(draftGpaNone); | ||
| const parsedDraftGpaLow = draftGpaLow.trim() === '' ? Number.NaN : Number.parseFloat(draftGpaLow); | ||
| const parsedDraftGpaHigh = draftGpaHigh.trim() === '' ? Number.NaN : Number.parseFloat(draftGpaHigh); | ||
| const thresholdsAreValid = | ||
| Number.isFinite(parsedDraftGpaNone) && | ||
| parsedDraftGpaNone >= 0 && | ||
| Number.isFinite(parsedDraftGpaLow) && | ||
| parsedDraftGpaLow >= 0 && | ||
| Number.isFinite(parsedDraftGpaHigh) && | ||
| parsedDraftGpaHigh >= 0; |
There was a problem hiding this comment.
thresholdsAreValid currently requires all three draft fields to be non-empty finite numbers. However openThresholdsModal initializes missing values as empty strings and saveThresholds explicitly treats empty strings as “keep current saved value”. As a result, users can no longer leave any threshold blank (even to keep the current value), and the Save button stays disabled. Consider treating empty strings as valid (e.g., validate each field as either blank or a finite >= 0 number) to match the save/merge behavior.
| const parsedDraftGpaNone = draftGpaNone.trim() === '' ? Number.NaN : Number.parseFloat(draftGpaNone); | |
| const parsedDraftGpaLow = draftGpaLow.trim() === '' ? Number.NaN : Number.parseFloat(draftGpaLow); | |
| const parsedDraftGpaHigh = draftGpaHigh.trim() === '' ? Number.NaN : Number.parseFloat(draftGpaHigh); | |
| const thresholdsAreValid = | |
| Number.isFinite(parsedDraftGpaNone) && | |
| parsedDraftGpaNone >= 0 && | |
| Number.isFinite(parsedDraftGpaLow) && | |
| parsedDraftGpaLow >= 0 && | |
| Number.isFinite(parsedDraftGpaHigh) && | |
| parsedDraftGpaHigh >= 0; | |
| const isValidThresholdDraft = (value: string) => { | |
| if (value.trim() === '') return true; | |
| const parsedValue = Number.parseFloat(value); | |
| return Number.isFinite(parsedValue) && parsedValue >= 0; | |
| }; | |
| const thresholdsAreValid = | |
| isValidThresholdDraft(draftGpaNone) && | |
| isValidThresholdDraft(draftGpaLow) && | |
| isValidThresholdDraft(draftGpaHigh); |
Closes #86