Skip to content

Technical debt: Add client-side clamping for numeric inputs #4879

@coderabbitai

Description

@coderabbitai

Context

PR #4863 adds adjustmentCenter and adjustmentScale numeric inputs to the Adjustments Tab. During review, it was noted that these inputs use v-model.number with min/max HTML attributes but no explicit JavaScript clamping at save time.

Current Behavior

  • HTML min and max attributes serve as browser UI hints only
  • v-model.number will bind values typed outside the range (e.g., typing 300 when max="255")
  • Save functions assign values directly without Math.min/Math.max clamping
  • Out-of-range values are passed to MSP encoding

Codebase Pattern

This behavior is consistent across the entire codebase:

  • ConfigurationTab.vue: fpvCamAngleDegrees, small_angle, boardAlignment angles saved directly
  • AuxiliaryTab.vue, MotorsTab.vue, ReceiverTab.vue: Same pattern
  • Math.min/Math.max used only for UI calculations (drag logic, percentages), not data validation

Affected Fields in PR #4863

  • adjustment.adjustmentCenter (range: 0–255)
  • adjustment.adjustmentScale (range: 0–255)

Currently backed by uint16_t in firmware but UI constrained to 0–255.

Recommendation

This is technical debt that could be addressed in a future refactor:

  1. Add explicit clamping in save functions across all tabs
  2. Or add @input handlers to clamp on user input
  3. Consider a reusable validation composable for numeric inputs

Not required for PR #4863 since it follows the established pattern.

References

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions