Skip to content

fix(data-table): align collection filters and cell timezones - #589

Draft
IzumiSy wants to merge 4 commits into
fix/datetime-filter-rfc3339from
fix/collection-datetime-timezone
Draft

IzumiSy wants to merge 4 commits into
fix/datetime-filter-rfc3339from
fix/collection-datetime-timezone

Conversation

@IzumiSy

@IzumiSy IzumiSy commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Follow-up to #546, stacked on fix/datetime-filter-rfc3339 so this PR contains only the remaining collection and cell timezone fixes.

The datetime filter toolbar serializes edited values as RFC 3339 instants, but initial filters, bookmarked URLs, and saved views can still send legacy timezone-less values before anyone re-applies a filter. Built-in date cells and the cell menu also use browser-local interpretation in paths where the toolbar uses the configured AppShell timezone. When those zones differ, the displayed value and generated query can disagree.

Design Decision

Normalize at the collection state boundary

Use existing tableMetadata to identify datetime fields and normalize initial state, addFilter, and setFilters before values reach queries or persistence callbacks. This covers URL and saved-view restoration without a second conversion in the URL parser or a mount effect that runs after the first query.

Hooks without metadata remain unchanged: field names and string values are not enough to identify datetime fields safely. No new public configuration is introduced.

Preserve instants and reject invalid input

Interpret supported timezone-less ISO datetime strings in the AppShell timezone while preserving the instant represented by explicit offsets. Reuse the existing temporal conversion logic from a shared internal helper for scalar values, arrays, and range bounds. Validate string inputs before permissive display parsing; invalid metadata-backed datetime filters throw TypeError instead of silently dropping constraints, and rejected updates preserve existing state.

Align built-in cells without shifting calendar dates

Pass the AppShell timezone into built-in timestamp rendering and cell-menu filter conversion. Format date-only values through a timezone-neutral branch so a calendar date stays unchanged, including dates skipped by a timezone transition. Custom renderers remain caller-owned.

Reuse column-scoped cell renderers

Constructing Intl.DateTimeFormat is substantially more expensive than using an existing formatter. Creating it inside each cell's render repeats that setup for every row and rerender, even though the formatting settings are shared across the column.

Date renderer instances retain lazily created Intl.DateTimeFormat objects for UTC calendar dates and AppShell-timezone timestamps. Memoize the built-in renderer instances per column so all rows share these formatters and row-only rerenders do not construct them again. Rebuild the renderer set when the ordered column array or AppShell timezone changes.

Keep the cache local to each DataTable rather than introducing a global cache. Date parsing and timezone conversion still happen per value; custom renderers retain precedence and are not cached by this mechanism.

Local microbenchmark

A single local Node.js v24.21.0 run measured each operation over 5,000 calls, after 200 warm-up calls:

Operation Total elapsed time
Parse a date-only value with parseDate(...).toDate("UTC") 3.6 ms
Normalize a timezone-less datetime in America/New_York 62.4 ms
Construct Intl.DateTimeFormat and format on every call 124.7 ms
Format with one reused Intl.DateTimeFormat instance 2.4 ms

The two formatter cases used identical en-US short-month/numeric-day/numeric-year options and America/New_York. These are directional, single-run microbenchmark results, not end-to-end DataTable, React render, or browser timings. They motivate avoiding repeated formatter construction; they do not imply the same speedup for the whole table, and parsing/timezone conversion costs remain.

Summary

  • Normalize metadata-backed datetime filters before initial queries and subsequent filter updates.
  • Align built-in date cells and cell-menu filters with the AppShell timezone while preserving date-only semantics.
  • Reuse column-scoped cell renderers and lazy date formatters across rows and row-only rerenders.
  • Add regressions for restoration, configured-zone differences, invalid input, and skipped calendar days; update authored documentation, generated outputs, and release metadata.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Code Metrics Report

main (94f6a5a) #589 (67445cf) +/-
Coverage 88.1% 88.4% +0.2%
Test Execution Time 2m20s 2m13s -7s
Details
  |                     | main (94f6a5a) | #589 (67445cf) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          88.1% |          88.4% | +0.2% |
  |   Files             |            207 |            206 |    -1 |
  |   Lines             |           6176 |           6175 |    -1 |
+ |   Covered           |           5446 |           5460 |   +14 |
+ | Test Execution Time |          2m20s |          2m13s |   -7s |

Code coverage of files in pull request scope (87.4% → 88.4%, patch 98.5%)

Files Coverage +/- Patch Coverage Status
packages/core/src/components/data-table/cell-renderers.tsx 96.9% +3.4% 100.0% modified
packages/core/src/components/data-table/data-table.tsx 91.0% -1.0% 100.0% modified
packages/core/src/components/data-table/i18n.ts 45.8% -0.4% - affected
packages/core/src/components/data-table/pagination.tsx 94.1% -0.9% - affected
packages/core/src/components/data-table/toolbar.tsx 82.3% +3.7% - modified
packages/core/src/components/data-table/use-data-table.ts 98.8% -0.2% - affected
packages/core/src/hooks/use-collection-variables.ts 94.2% +1.1% 100.0% modified
packages/core/src/lib/collection-url-state.ts 94.3% +2.2% - modified
packages/core/src/lib/temporal-filter-values.ts 94.8% +94.8% 93.7% renamed
src/components/data-table/filter-value-utils.ts 0.0% -95.6% - affected
src/components/data-table/selection-bar.tsx 0.0% -100.0% - affected

Reported by octocov

@IzumiSy

IzumiSy commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

…o fix/collection-datetime-timezone

# Conflicts:
#	docs-manifest.json

Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>

Copilot AI commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflict and merged fix/datetime-filter-rfc3339 into this branch. Merge commit: 096ee71.

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.

2 participants