diff --git a/internal/tui/datetime.go b/internal/tui/datetime.go index 6cad72ee..4f447ff4 100644 --- a/internal/tui/datetime.go +++ b/internal/tui/datetime.go @@ -255,9 +255,9 @@ func (p *dateTimePicker) handleKey(msg tea.KeyPressMsg) tea.Cmd { } } -// dateStep is the day-at-a-time keys. Both pairs are here because neither means anything -// else on a date field: the arrows are unbound in a single-line text input, and a + or a - -// cannot appear in YYYY-MM-DD, so typing one is only ever a step. +// dateStep is the day-at-a-time keys. The arrows are unbound in a single-line text input, +// and a + cannot appear in YYYY-MM-DD, so typing one is only ever a step. A - is the date's +// own separator, so it is typed into the field like any other character (hey-cli#368). func dateStep(msg tea.KeyPressMsg) (days int, stepped bool) { switch msg.Key().Code { case tea.KeyUp: @@ -268,8 +268,6 @@ func dateStep(msg tea.KeyPressMsg) (days int, stepped bool) { switch msg.String() { case "+", "=": return 1, true - case "-": - return -1, true } return 0, false } diff --git a/internal/tui/datetime_test.go b/internal/tui/datetime_test.go index 8951cb7f..a23d7d26 100644 --- a/internal/tui/datetime_test.go +++ b/internal/tui/datetime_test.go @@ -86,6 +86,17 @@ func TestDateTimePickerStepsTheDateByADay(t *testing.T) { } } +func TestDateTimePickerTypesTheDateSeparator(t *testing.T) { + picker := testPicker() + picker.focusFirst() + picker.dateInput.SetValue("2026-08") + + typeInto(t, picker, "-22") + if got := picker.date(); got != "2026-08-22" { + t.Errorf("after typing -22, date() = %q, want 2026-08-22", got) + } +} + func TestDateTimePickerAllDayHidesTheTimeAndTheZone(t *testing.T) { picker := testPicker() picker.setZoneName("Europe/Zagreb")