Skip to content

Conversation

@andrewkolos
Copy link
Collaborator

@andrewkolos andrewkolos commented Dec 18, 2025

Description

Fixes #543.

This change fixes quite a few issues with the DateTimeInput core catalog component:

Fix: Placeholder text indicates whether the component is meant for picking a date, a time, or both.

Previously, it always said Select a date/time.

Before After
image image

Fix: atomic updates for date+time mode (do not update date when time selection is cancelled). In addition, chosen times are consistently displayed in a localized format, regardless of whether date and/or time selection is enabled.

Previously, when picking a date+time, only the time would be shown (localized). When picking just the date (canceling out of the time selection), the value saved would be the date + midnight, formatted as a raw ISO 8601 string (not localized). Now, when time selection is cancelled, we instead do not update the value at all. I believe this would be the least surprising behavior for most users.

⚠️ edit: since these videos were made, this PR now uses the full date format, which includes the day of the week, full month, year, and time. In these videos, the medium format was being used instead.

before_picking_stuff.mp4
after_picking_stuff.mp4

Fix: When in date-only mode, only save the date (don't append midnight as the time)

before_picking_date.mp4
after_picking_date.mp4

This PR add tests coverage for these fixes as well as a bunch of other tests that were missing to begin with.

Pre-launch Checklist

@andrewkolos andrewkolos changed the title Fix DateTimeInput: reliable updates, localized display, and time-only… fix(genui): fix DateTimeInput core catalog item Dec 18, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly improves the "DateTimeInput" component by addressing issues like placeholder text, atomic updates, and output formats, and enhances stability with comprehensive tests. However, a medium-severity vulnerability was identified: the new code does not properly validate the length of the "value" before parsing it as a date, which could lead to a client-side Denial of Service due to uncontrolled resource consumption. Additionally, a few minor suggestions have been made to further enhance code readability and maintainability.

Comment on lines 165 to 166
firstDate: DateTime(2000),
lastDate: DateTime(2100),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The firstDate and lastDate for the date picker are hardcoded. To make this component more reusable and flexible, consider allowing these to be configured as properties on the DateTimeInput component. You would need to update the schema and _DateTimeInputData extension type as well, using the current values as defaults.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm shall we just make these super broad, e.g make the min year 0 or something? I assume it still opens on the current month etc?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the range to be [DateTime(-9999), DateTime(9999)], effectively removing the limits. The UI seems to handle this gracefully (year picking widget lazily renders years and will incrementally render more years as you scroll near a boundary).

Copy link
Collaborator

@jacobsimionato jacobsimionato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey this looks great! Sorry if it wasn't ready for review yet, but was just driving by :-D.

Comment on lines 165 to 166
firstDate: DateTime(2000),
lastDate: DateTime(2100),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm shall we just make these super broad, e.g make the min year 0 or something? I assume it still opens on the current month etc?

"path": "/myTime"
},
"enableDate": false,
"outputFormat": "time_only"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm I'm not sure what the intention of this parameter was actually. Perhaps a format string e.g. YYYY-MM-DD ? I'm going to propose removing it from the spec...

For now, maybe we should ignore it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I imagine it being a format string like you said. The problem that there is no universally accepted datetime formatting string. That could make supporting custom date formatting a very tricky problem for some (many?) renderers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output format was already being ignored here. I went ahead and removed the parameter entirely from the code.

@andrewkolos andrewkolos marked this pull request as ready for review December 18, 2025 21:39
@andrewkolos andrewkolos merged commit da1de1d into flutter:main Dec 18, 2025
36 checks passed
@andrewkolos andrewkolos deleted the fix-date-time-picker branch December 18, 2025 21:41
@jacobsimionato
Copy link
Collaborator

Hey btw I proposed to remove the output format param entirely in google/A2UI#353 . I'll probably quietly merge that if no-one complains!

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.

date_time_input in Core Catalog looks and behaves poorly

2 participants