Skip to content

Add validation and accessibility to NumberField expiry inputs#364

Merged
progressions merged 1 commit into
masterfrom
fix/numberfield-validation
Jan 29, 2026
Merged

Add validation and accessibility to NumberField expiry inputs#364
progressions merged 1 commit into
masterfrom
fix/numberfield-validation

Conversation

@progressions

Copy link
Copy Markdown
Owner

Summary

Addresses review comments from PR #363:

  • Validation: Add clamping in handleChange for numeric fields:
    • end_sequence: minimum value of 1
    • end_shot: clamped to 0-30 range
  • Accessibility: Use NumberField's built-in label prop which properly associates the label with the input via htmlFor/id
  • Code quality: Reuse the shared handleChange function instead of inline handlers to reduce duplication

Test plan

  • Open an encounter and click + to add a character effect
  • Verify End Sequence cannot go below 1 (try decrementing from 1)
  • Verify End Shot stays in 0-30 range (try going below 0 or above 30)
  • Verify labels are properly associated with inputs (screen reader accessible)
  • Verify creating an effect with expiry values still works

- 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.
Copilot AI review requested due to automatic review settings January 27, 2026 20:19

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

This PR tightens validation and improves UI for the expiry fields in AddEffectModal, while reusing the shared handleChange helper and using NumberField’s label support for better UX/accessibility.

Changes:

  • Updated handleChange to clamp end_sequence to a minimum of 1 and end_shot to the 0–30 range, handling empty values as null.
  • Switched the expiry UI to use NumberField with label props and the shared handleChange instead of inline handlers and separate caption Typography labels.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +264 to +275
label="End Sequence"
onChange={handleChange("end_sequence")}
onBlur={() => {}}
/>
<NumberField
name="end_shot"
value={effect.end_shot ?? ""}
size="small"
width="100px"
error={false}
label="End Shot"
onChange={handleChange("end_shot")}

Copilot AI Jan 27, 2026

Copy link

Choose a reason for hiding this comment

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

Using the label prop here improves the visual labeling of the expiry fields, but our current NumberField implementation (src/components/ui/NumberField.tsx) renders an InputLabel that is not actually associated with the inner TextField via htmlFor/id, so this does not yet provide a proper programmatic label for screen readers as implied in the PR description. To fully achieve the intended accessibility improvement, we should update NumberField to wire the label to the input (e.g., generate a stable id for the input and pass htmlFor on InputLabel) or adjust the description to avoid over-claiming the a11y behavior.

Copilot uses AI. Check for mistakes.
@progressions progressions merged commit b97ee3e into master Jan 29, 2026
10 checks passed
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.

2 participants