Skip to content

feat(datagrid): add native date/time picker for date columns (#1405)#1410

Merged
datlechin merged 8 commits into
mainfrom
feat/1405-datetime-picker
May 24, 2026
Merged

feat(datagrid): add native date/time picker for date columns (#1405)#1410
datlechin merged 8 commits into
mainfrom
feat/1405-datetime-picker

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

Adds a native date/time picker for DATE, DATETIME, TIMESTAMP, and TIME cells in the data grid. Click the chevron on a date cell to open an NSDatePicker calendar/clock popover and pick a value visually.

The picker augments inline editing, it does not replace it:

  • Double-click still opens the inline text editor (type, paste, expressions).
  • Right-click Set Value still offers NOW() / CURRENT_TIMESTAMP / CURRENT_DATE / CURRENT_TIME / NULL.
  • The chevron opens the picker. Three distinct paths, matching the datagrid convention.

This is the capability removed in #1233. That picker was removed because it blocked text editing and was the only way to edit a date cell. This one sits alongside the inline editor, so it adds the visual picker back without that regression.

How it works

  • NSDatePicker, style .clockAndCalendar, mode .single, wrapped in an NSViewRepresentable, shown via the existing PopoverPresenter (.semitransient, like every other cell picker). OK commits; Cancel or click-away commits nothing.
  • Components adapt to the column type: DATE shows the calendar only, TIME the clock only, DATETIME / TIMESTAMP both.
  • Write-back preserves the value's existing shape. A new DateEditingService decomposes the cell string into date, time, fractional-seconds, and timezone-offset parts, lets the picker edit only the calendar/clock fields, and re-emits the fraction and offset verbatim. Naive types are pinned to UTC so the digits shown match the digits stored (no local-zone drift). NULL or unparseable cells start at the current date/time and write the column's default format.
  • ColumnType.isTimeOnly now strips a precision suffix, so TIME(6) is treated as time-only. This also fixes display formatting for those columns.

Files

New:

  • DateEditingService.swift for the parse/format round-trip
  • DateTimePickerContentView.swift for the SwiftUI popover and NSDatePicker wrapper

Changed: DataGridCellKind (new .date case), DataGridCellView (chevron rendering, hit-test, click), DataGridCellRegistry.resolveKind, DataGridView+Click (chevron dispatch), DataGridView+Popovers (showDateTimePickerPopover), ColumnType.isTimeOnly, CHANGELOG.md, and the stale docs/features/data-grid.mdx section.

Tests

DateEditingServiceTests covers MySQL / ISO / Z / offset round-trips, fractional-second preservation, fraction and offset together, date-only, time-only, the edit-then-format path, NULL / empty / whitespace, unparseable input, and the per-type default format. ColumnTypeTests gains TIME(6), TIMESTAMP(6), and TIMESTAMPTZ precision cases.

Test plan

  • Click the chevron on a DATETIME cell. Calendar and clock popover opens at the current value. Pick a date and time, OK. Cell shows the new value, row is marked modified, Save emits the right UPDATE.
  • DATE cell shows calendar only; TIME cell shows clock only.
  • Double-click a date cell still opens the inline text editor.
  • Open the picker, click away without changing anything. Cell is unchanged, row not marked modified.
  • A TIMESTAMP value with fractional seconds keeps them after editing.
  • A timestamptz value keeps its offset after editing.
  • A NULL date cell opens the picker at the current time; OK writes a value in the column's format.
  • Right-click Set Value still offers NOW() / CURRENT_TIMESTAMP / NULL.

Closes #1405

@datlechin datlechin force-pushed the feat/1405-datetime-picker branch from 9b94169 to 04338c8 Compare May 24, 2026 08:32
@datlechin datlechin merged commit dd29fe5 into main May 24, 2026
2 checks passed
@datlechin datlechin deleted the feat/1405-datetime-picker branch May 24, 2026 10:13
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.

Datetime picker

1 participant