diff --git a/internal/tui/datetime.go b/internal/tui/datetime.go index 4f447ff4..d3fbc4f8 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. 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). +// dateStep is the day-at-a-time keys: the arrows, which are unbound in a single-line text +// input. Nothing printable steps, because a date is typed as YYYY-MM-DD and every key that +// can appear in one has to reach the input — a - that stepped instead could never be typed. func dateStep(msg tea.KeyPressMsg) (days int, stepped bool) { switch msg.Key().Code { case tea.KeyUp: @@ -265,10 +265,6 @@ func dateStep(msg tea.KeyPressMsg) (days int, stepped bool) { case tea.KeyDown: return -1, true } - switch msg.String() { - case "+", "=": - return 1, true - } return 0, false } diff --git a/internal/tui/datetime_test.go b/internal/tui/datetime_test.go index a23d7d26..289f296a 100644 --- a/internal/tui/datetime_test.go +++ b/internal/tui/datetime_test.go @@ -74,9 +74,9 @@ func TestDateTimePickerStepsTheDateByADay(t *testing.T) { t.Errorf("after two downs, date() = %q, want 2026-08-21", got) } - typeInto(t, picker, "+") + picker.handleKey(tea.KeyPressMsg{Code: tea.KeyUp}) if got := picker.date(); got != "2026-08-22" { - t.Errorf("after +, date() = %q, want 2026-08-22", got) + t.Errorf("after up, date() = %q, want 2026-08-22", got) } picker.dateInput.SetValue("next tuesday") @@ -97,6 +97,20 @@ func TestDateTimePickerTypesTheDateSeparator(t *testing.T) { } } +func TestDateTimePickerTypesADateWithItsHyphens(t *testing.T) { + picker := testPicker() + picker.focusFirst() + picker.dateInput.SetValue("") + + typeInto(t, picker, "2026-09-14") + if got := picker.date(); got != "2026-09-14" { + t.Errorf("after typing 2026-09-14, date() = %q", got) + } + if got := picker.problem(); got != "" { + t.Errorf("problem() = %q, want none for a typed date", got) + } +} + func TestDateTimePickerAllDayHidesTheTimeAndTheZone(t *testing.T) { picker := testPicker() picker.setZoneName("Europe/Zagreb")