-
Notifications
You must be signed in to change notification settings - Fork 285
fix(dashboard): handle empty input for min and max values (#3410, #3411) #334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,7 +119,7 @@ const EditPropsDialog = ({ open, onClose, onSave, isNew, props }: EditPropsDialo | |
| <DenseFilledTextField | ||
| type="number" | ||
| value={editProps?.min || ""} | ||
| onChange={(e) => setEditProps({ ...editProps, min: parseInt(e.target.value) } as CustomProps)} | ||
| onChange={(e) => setEditProps({ ...editProps, min: e.target.value === "" ? undefined : parseInt(e.target.value) } as CustomProps)} | ||
| /> | ||
|
Comment on lines
121
to
123
|
||
| {fieldType.minDes && <NoMarginHelperText>{t(fieldType.minDes)}</NoMarginHelperText>} | ||
| </FormControl> | ||
|
|
@@ -132,7 +132,7 @@ const EditPropsDialog = ({ open, onClose, onSave, isNew, props }: EditPropsDialo | |
| type="number" | ||
| required={fieldType.maxRequired} | ||
| value={editProps?.max || ""} | ||
| onChange={(e) => setEditProps({ ...editProps, max: parseInt(e.target.value) } as CustomProps)} | ||
| onChange={(e) => setEditProps({ ...editProps, max: e.target.value === "" ? undefined : parseInt(e.target.value) } as CustomProps)} | ||
| /> | ||
|
Comment on lines
132
to
136
|
||
| {fieldType.maxDes && <NoMarginHelperText>{t(fieldType.maxDes)}</NoMarginHelperText>} | ||
| </FormControl> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value={editProps?.min || ""}will render0(and alsoNaN) as an empty string because of the||fallback. That makes the UI inconsistent with the underlying state (e.g., min=0 looks cleared) and can mask invalid values. Use a nullish check (e.g.,??) and/or explicitly handleNaNso onlyundefined/nullbecomes empty.