Use NumberField for expiry inputs in character effects dialog#363
Conversation
Replace TextField type="number" with NumberField components for the end_sequence and end_shot fields, matching the pattern used in AddFightEffectModal. NumberField provides increment/decrement buttons that slide in on hover for better UX.
There was a problem hiding this comment.
Pull request overview
Replaces the expiry inputs in the character Add Effect modal with the shared NumberField component to align UI/UX with other effect dialogs and provide increment/decrement controls.
Changes:
- Swap
TextField type="number"forNumberFieldforend_sequenceandend_shot. - Update layout around expiry inputs to use caption labels and fixed-width fields.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <NumberField | ||
| name="end_sequence" | ||
| value={effect.end_sequence ?? ""} | ||
| size="small" | ||
| width="100px" | ||
| error={false} | ||
| onChange={(e: React.ChangeEvent<HTMLInputElement>) => { | ||
| const val = e.target.value | ||
| setEffect(prev => ({ | ||
| ...prev, | ||
| end_sequence: val === "" ? null : Number(val), | ||
| })) | ||
| }} |
There was a problem hiding this comment.
This change drops the previous numeric constraints (min: 1 for end_sequence). With NumberField’s +/- controls, users can now decrement into invalid values (e.g., 0 or negative) and submit them. Please reintroduce a lower bound (e.g., clamp in the onChange handler, or extend NumberField to accept/enforce min).
| onChange={(e: React.ChangeEvent<HTMLInputElement>) => { | ||
| const val = e.target.value | ||
| setEffect(prev => ({ | ||
| ...prev, | ||
| end_sequence: val === "" ? null : Number(val), | ||
| })) | ||
| }} |
There was a problem hiding this comment.
The onChange handler here duplicates the existing handleChange("end_sequence") logic (which already handles nullable numeric fields). Reusing the shared handler would reduce duplication and keep numeric parsing behavior consistent across the modal.
| setEffect(prev => ({ | ||
| ...prev, | ||
| end_shot: val === "" ? null : Number(val), |
There was a problem hiding this comment.
This change drops the previous end_shot bounds (min: 0, max: 30). With NumberField’s +/- controls (and no max), users can now enter negative shots or values > 30 and submit them. Please enforce the expected range (clamp in onChange, or extend NumberField to support min/max and pass them through).
| setEffect(prev => ({ | |
| ...prev, | |
| end_shot: val === "" ? null : Number(val), | |
| if (val === "") { | |
| setEffect(prev => ({ | |
| ...prev, | |
| end_shot: null, | |
| })) | |
| return | |
| } | |
| let num = Number(val) | |
| if (Number.isNaN(num)) { | |
| return | |
| } | |
| if (num < 0) { | |
| num = 0 | |
| } else if (num > 30) { | |
| num = 30 | |
| } | |
| setEffect(prev => ({ | |
| ...prev, | |
| end_shot: num, |
| <Typography | ||
| variant="caption" | ||
| color="text.secondary" | ||
| sx={{ mb: 0.5 }} | ||
| > | ||
| End Sequence | ||
| </Typography> | ||
| <NumberField | ||
| name="end_sequence" | ||
| value={effect.end_sequence ?? ""} | ||
| size="small" | ||
| width="100px" |
There was a problem hiding this comment.
The new NumberField inputs no longer have an associated form label (the Typography caption isn’t programmatically tied to the input), which is an accessibility regression vs the previous TextField label prop. Consider wiring an accessible label via label/id + htmlFor (or aria-label/aria-labelledby)—either by enhancing NumberField to expose these props properly, or by using a labeled MUI TextField under the hood.
- Add clamping in handleChange: end_sequence min 1, end_shot 0-30 - Use NumberField's label prop for proper accessibility (htmlFor/id) - Reuse handleChange instead of inline handlers to reduce duplication Addresses review comments from PR #363.
- Add clamping in handleChange: end_sequence min 1, end_shot 0-30 - Use NumberField's label prop for proper accessibility (htmlFor/id) - Reuse handleChange instead of inline handlers to reduce duplication Addresses review comments from PR #363.
Summary
TextField type="number"withNumberFieldcomponents for the end_sequence and end_shot fields in AddEffectModalTest plan