Skip to content

Equip date/time input fields with a "now" option#141

Open
Oleg-Melnik wants to merge 3 commits into
masterfrom
feature/datetime-now-option
Open

Equip date/time input fields with a "now" option#141
Oleg-Melnik wants to merge 3 commits into
masterfrom
feature/datetime-now-option

Conversation

@Oleg-Melnik

@Oleg-Melnik Oleg-Melnik commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Closes #140.

Summary

Adds an opt-in "now" affordance to DateTimeField that fills the field with the
current date and time, so the user doesn't have to type it by hand when
recording something at the moment it happens. The current moment is sourced
through WallClock, and the filled value is truncated to the resolution of
dateTimePattern, keeping the stored value consistent with the displayed text.

Changes

  • DateTimeField.nowOptionEnabled — opt-in property (off by default) that
    shows a button within the field and enables the Ctrl+N shortcut.
  • DateTimeField.nowOptionAffordance — optional custom renderer, receiving a
    fillNow callback, used instead of the default button.
  • formatDateTime preserves sub-second precision when the pattern includes
    it; otherwise the value is truncated to the pattern's resolution.
  • WallClock.now — exposes the current moment as an Instant, the single
    point through which time-dependent behavior obtains the current time.
  • InputFieldapplyValue sets a value programmatically (reusing the
    normal parse/validate/dirty bookkeeping), and a handleKeyEvent hook lets
    subclasses implement field-specific keyboard shortcuts.
  • The default button keeps the field's height, gives hover/press/focus feedback
    and a tooltip, and exposes full button semantics (role, accessible click
    action, disabled state, focusability, and Enter/Space activation).
  • Adds compose.materialIconsExtended to the proto module for the button
    icon.
  • Tests: WallClockSpec, and DateTimeFieldSpec cases for pattern truncation
    and sub-second round trips.

Reviewer notes

Mouse activation of the default button uses low-level pointer events rather than
clickable/IconButton, because that gesture is intermittently cancelled when
placed inside the text field's decoration slot.

Oleg-Melnik and others added 3 commits July 24, 2026 23:43
…ing.

Introduce a reusable base for setting an `InputField` value in code:

- `InputField.applyValue` sets the field's value programmatically, reusing the
  same parsing, validation, and dirty-state bookkeeping as a user's edit (via
  the extracted `commitRawText`), so the displayed text stays consistent with
  the value and any prior validation error is cleared.
- `InputField.handleKeyEvent` is an overridable hook, consulted before the input
  reviser, that lets subclasses implement field-specific keyboard shortcuts.
- `WallClock.now` exposes the current moment as an `Instant`, the single point
  through which time-dependent behavior should obtain the current time.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add an opt-in affordance that fills the field with the current date and time,
so the user doesn't have to type it by hand when recording something at the
moment it happens.

- `nowOptionEnabled` turns on a button, shown within the field, and the Ctrl+N
  keyboard shortcut; `nowOptionAffordance` allows customizing the button.
- The current moment comes from `WallClock`, and the stored value is truncated
  to the resolution of `dateTimePattern`, so it stays consistent with the text
  shown in the field (`formatDateTime` preserves sub-second precision when the
  pattern includes it).
- The default button is a compact icon that keeps the field's height, gives
  hover/press/focus feedback, shows a tooltip, and exposes full button
  semantics (role, accessible click action, disabled state, focusability, and
  Enter/Space activation). Mouse activation uses low-level pointer events, since
  a `clickable`/`IconButton` gesture is intermittently cancelled inside the text
  field's decoration.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Regenerate the `pom.xml` and `dependencies.md` reports accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Oleg-Melnik Oleg-Melnik self-assigned this Jul 24, 2026
@Oleg-Melnik
Oleg-Melnik marked this pull request as draft July 24, 2026 20:48
@Oleg-Melnik
Oleg-Melnik marked this pull request as ready for review July 24, 2026 20:56
@Oleg-Melnik
Oleg-Melnik requested review from armiol and dpikhulya July 24, 2026 20:57
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.

Equip date/time input fields with a "now" option

3 participants