feat(opal): move between segments with the arrow keys

Merged
RA
2d ago
+121-7

Description

Segmented fields (InputTime, InputDatePicker) now move between segments with the arrow keys. ArrowLeft at the start of a segment focuses the previous segment, with the caret at its end. ArrowRight at the end focuses the next segment, with the caret at its start. Shift+Arrow and caret moves inside a segment stay native.

The change is in the shared makeSegmentKeyDownHandler (inputs/segmented.tsx), which now takes an optional next-segment ref. Both pickers pass it.

First PR of a stack: this โ†’ InputCurrency โ†’ cost-overrides modal.


Summary by cubic

Adds arrow key navigation between segments in InputTime and InputDatePicker. ArrowLeft at a segment's start moves focus to the previous segment's end, and ArrowRight at the end moves to the next segment's start.

Only a plain arrow with a collapsed caret crosses an edge; Shift/Ctrl/Meta/Alt arrows and mid-segment moves stay native. Handled in the shared makeSegmentKeyDownHandler, which now takes an optional next-segment ref, and tests cover edge crossing and all guard cases.

Summary by CodeRabbit

  • Bug Fixes
    • Improved keyboard navigation in segmented date and time inputs.
    • Pressing ArrowLeft at the beginning of a segment now moves focus to the previous segment.
    • Pressing ArrowRight at the end of a segment now moves focus to the next segment.
    • Caret placement is preserved when moving between segments, while selection and mid-segment navigation continue to work as expected.