Skip to content

Bugfix/fix numeric field input - #88

Merged
LoganSutton13 merged 3 commits into
mainfrom
bugfix/fix-numeric-field-input
Apr 14, 2026
Merged

LoganSutton13 merged 3 commits into
mainfrom
bugfix/fix-numeric-field-input

Conversation

@LoganSutton13

Copy link
Copy Markdown
Owner

Closes #86

- 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.
Copilot AI review requested due to automatic review settings April 14, 2026 19:33
@LoganSutton13
LoganSutton13 merged commit 77aee29 into main Apr 14, 2026
4 checks passed
@LoganSutton13
LoganSutton13 deleted the bugfix/fix-numeric-field-input branch April 14, 2026 19:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +287 to +296
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;

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix numeric input fields to not have leading 0

2 participants