Repository navigation
Conversation
DataViews previously recognized date and datetime fields but could not model a time-only value without attaching a synthetic date or timezone. Register a native time control and field definition that preserves normalized HTML time strings, supports scalar comparison and sorting, and is documented and exercised in Storybook and unit tests.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
Associate the new time field enhancement with #80831 so the package changelog validation can verify its pull request reference.
There was a problem hiding this comment.
Pull request overview
Adds first-class time support to the DataViews field system and DataForm controls, allowing time-only values (e.g. 14:30) to be displayed, edited, filtered, and sorted without introducing date/timezone semantics.
Changes:
- Adds a new
timefield type (operators, formatting, validation wiring) and registers it in the field-type registry and public type union. - Adds a dedicated DataForm
timecontrol built on the shared validated input control. - Updates docs, Storybook stories, and tests to cover normalization and editing for
timefields.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/dataviews/src/types/field-api.ts | Extends the public FieldTypeName union to include time. |
| packages/dataviews/src/field-types/time.tsx | Introduces the time field type definition (render/edit/operators/sort/validation). |
| packages/dataviews/src/field-types/index.tsx | Registers the new time field type in normalizeFields. |
| packages/dataviews/src/field-types/test/normalize-fields.ts | Adds normalization expectations for time fields (formatting, operators, sorting). |
| packages/dataviews/src/components/dataform-controls/utils/validated-input.tsx | Extends validated input typings to allow type="time". |
| packages/dataviews/src/components/dataform-controls/time.tsx | Adds a new DataForm control that renders a native time input via validated input. |
| packages/dataviews/src/components/dataform-controls/index.tsx | Registers the new time control in the bundled controls map. |
| packages/dataviews/src/dataform/test/dataform.tsx | Adds a DataForm test ensuring time fields render as <input type="time"> and edit correctly. |
| packages/dataviews/src/field-types/stories/index.story.tsx | Adds story data/field config and a dedicated Storybook story for time. |
| packages/dataviews/README.md | Documents the new time type, the time control, and valid operators. |
| packages/dataviews/CHANGELOG.md | Notes the enhancement in the package changelog. |
| import type { FieldType } from '../types/private'; | ||
| import { | ||
| OPERATOR_GREATER_THAN, | ||
| OPERATOR_GREATER_THAN_OR_EQUAL, | ||
| OPERATOR_IS, | ||
| OPERATOR_IS_NOT, | ||
| OPERATOR_LESS_THAN, | ||
| OPERATOR_LESS_THAN_OR_EQUAL, | ||
| } from '../constants'; | ||
| import render from './utils/render-default'; | ||
| import sort from './utils/sort-text'; | ||
| import isValidRequired from './utils/is-valid-required'; | ||
| import isValidElements from './utils/is-valid-elements'; | ||
| import getValueFormatted from './utils/get-value-formatted-default'; | ||
|
|
||
| export default { | ||
| type: 'time', | ||
| render, | ||
| Edit: 'time', | ||
| sort, | ||
| enableSorting: true, | ||
| enableGlobalSearch: false, |
|
|
||
| - DataViews: Add a `time` field type and DataForm control. | ||
| - DataViews: Add Shift+Click range selection through a shared `useSelectionProps` hook that layouts can adopt, wired up in the table and grid layouts.[#80046](https://github.com/WordPress/gutenberg/pull/80046) | ||
| - DataViewsPicker: Add Shift+Click range selection to the `picker-table`, `picker-grid`, and `picker-activity` layouts. [#80413](https://github.com/WordPress/gutenberg/pull/80413) |
|
That's a eerie coincidence 😄 . I had opened a similar PR about 10 minutes before yours. Curious to see though the differences because mine is lot bigger. |
|
Size Change: +322 B (0%) Total Size: 7.76 MB 📦 View Changed
|
|
Haha @ntsekouras, what a coincidence. It looks like yours supports more than mine; happy to close this one in favor of yours (or try to at least support the same features so we can compare both 😄 ) |
It seems so, and based on yours though, it might be simplified in a few pieces. Wanna collaborate on mine? |
|
@ntsekouras sure! I'll leave this as is then 🙌 |
|
Flaky tests detected in 590aa3f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/30438919038
|
|
Closing in favor of #80830 |
What?
Adds first-class support for time-only fields to DataViews and DataForm.
Field authors can now use
type: 'time'to display and edit normalized time values such as14:30, without attaching an artificial date or timezone.Why?
DataViews currently supports
dateanddatetime, but neither correctly represents a value that contains only a time. Otherwise, consumers have to use a generic text field or introduce date and time zone semantics that do not belong to the value.How?
The new field type composes the existing DataViews field infrastructure:
DataViews/FieldTypes/timeStorybook story.Multi-selection operators are intentionally excluded because the native time control represents a single scalar value.
Testing Instructions
Open Storybook locally and visit FieldTypes > All / time
CleanShot.2026-07-29.at.12.07.14.mp4
Use of AI Tools
Codex was used to investigate the existing DataViews field architecture, implement the change, add tests and documentation, and review the resulting diff. I reviewed the generated changes and take responsibility for the final implementation.