impr: native support for number/boolean in InputField (@fehmer)#8197
Draft
fehmer wants to merge 3 commits into
Draft
impr: native support for number/boolean in InputField (@fehmer)#8197fehmer wants to merge 3 commits into
fehmer wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds typed/natively-parsed numeric/boolean handling to the shared InputField, then simplifies several settings/modals to stop manually parseFloat/parseInt and to rely on schema validation + numeric field values.
Changes:
- Tighten
InputFieldtypeprop + add value conversion to support non-string field values. - Update settings/custom-settings to submit numeric values directly and reuse
fromSchema(...)number validators. - Update modals (custom word amount, custom generator) to store numeric form values; extend
InputFieldunit tests for numbers.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/ts/components/ui/form/InputField.tsx | Typed type union; converts field values to/from string; updates input binding |
| frontend/src/ts/components/pages/settings/SettingsPage.tsx | AutoSetting number submit/validation now uses numeric values + fromSchema |
| frontend/src/ts/components/pages/settings/custom-setting/PaceCaret.tsx | Removes float parsing; schema validator directly on numeric value |
| frontend/src/ts/components/pages/settings/custom-setting/MinSpeed.tsx | Removes float parsing; schema validator directly on numeric value |
| frontend/src/ts/components/pages/settings/custom-setting/MinBurst.tsx | Removes float parsing; schema validator directly on numeric value |
| frontend/src/ts/components/pages/settings/custom-setting/MinAcc.tsx | Removes float parsing; schema validator directly on numeric value |
| frontend/src/ts/components/pages/settings/custom-setting/MaxLineWidth.tsx | Removes float parsing; schema validator directly on numeric value |
| frontend/src/ts/components/modals/CustomWordAmountModal.tsx | Form value is now numeric; validator uses zod schema via fromSchema |
| frontend/src/ts/components/modals/CustomGeneratorModal.tsx | DefaultValues + submit handling now treats lengths/count as numbers |
| frontend/tests/components/ui/form/InputField.spec.tsx | Field helper updated for non-string defaults; adds number input test |
Comment on lines
+14
to
+23
| type?: | ||
| | "text" | ||
| | "textarea" | ||
| | "password" | ||
| | "email" | ||
| | "number" | ||
| | "range" | ||
| | "date" | ||
| | "datetime-local" | ||
| | "checkbox"; |
Comment on lines
94
to
+98
| onInput={(e) => { | ||
| props.field().handleChange(e.target.value); | ||
| const value: unknown = convertStringToValue( | ||
| props.field().state.value, | ||
| e.target.value, | ||
| ); |
Comment on lines
+164
to
+169
| function convertValueToString(input: unknown | undefined): string { | ||
| if (input === undefined || input === null) return ""; | ||
| if (typeof input === "boolean") return input ? "true" : "false"; | ||
| if (typeof input === "number") return input.toString(); | ||
| return input as string; | ||
| } |
Comment on lines
+67
to
+70
| it("calls handleChange on input for number", async () => { | ||
| const field = makeField("name", 2.5); | ||
| render(() => <InputField field={() => field} type="number" />); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.