Skip to content

fixed stale datetime picker default value#910

Open
VegardHV wants to merge 2 commits into
mainfrom
bug/vhv-stale-date-picker-with-default-value
Open

fixed stale datetime picker default value#910
VegardHV wants to merge 2 commits into
mainfrom
bug/vhv-stale-date-picker-with-default-value

Conversation

@VegardHV

@VegardHV VegardHV commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Description of Change

Date pickers used DateTime.Now as their default value. That default was read only once and then shared by every picker that also have no value of their own, so they all showed the same stale datetime until the app was restarted.

How to reproduce (in a version before the fix)

  1. Open Components > Saving (the picker has no date set).
  2. Note the time it shows.
  3. Go back out and wait a minute or two.
  4. Open it again and see that the time has not updated.

Fixed by using defaultValueCreator to set a default time upon creation of each individual picker.

Todos

  • I have tested on an Android device.
  • I have tested on an iOS device.
  • I have supported accessibility

Copilot AI review requested due to automatic review settings June 26, 2026 13:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Pull request overview

This PR fixes an issue where picker controls could display a “frozen” default date/time because DateTime.Now was evaluated once at static initialization and reused across instances. The fix switches these bindable properties to use defaultValueCreator so each picker instance gets a fresh “now” value when created.

Changes

  • Updated SelectedDate / SelectedDateTime bindable properties to use defaultValueCreator instead of a static DateTime.Now default.
  • Added explanatory comments documenting why defaultValueCreator is needed.
  • Added a changelog entry describing the consumer-visible behavior fix.
📁 File summary (4 files changed)
File Description
src/library/DIPS.Mobile.UI/Components/Pickers/DatePicker/HorizontalInLine/HorizontalInlineDatePicker.Properties.cs Uses defaultValueCreator to avoid shared stale default date/time.
src/library/DIPS.Mobile.UI/Components/Pickers/DatePicker/DatePicker.Properties.cs Uses defaultValueCreator for per-instance default SelectedDate.
src/library/DIPS.Mobile.UI/Components/Pickers/DateAndTimePicker/DateAndTimePicker.Properties.cs Uses defaultValueCreator for per-instance default SelectedDateTime.
CHANGELOG.md Documents the fix as a patch release entry.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/library/DIPS.Mobile.UI/Components/Pickers/DatePicker/HorizontalInLine/HorizontalInlineDatePicker.Properties.cs Per-instance default date/time via defaultValueCreator.
src/library/DIPS.Mobile.UI/Components/Pickers/DatePicker/DatePicker.Properties.cs Per-instance default date/time via defaultValueCreator.
src/library/DIPS.Mobile.UI/Components/Pickers/DateAndTimePicker/DateAndTimePicker.Properties.cs Per-instance default date/time via defaultValueCreator.
CHANGELOG.md Adds patch note for the default-value staleness fix.

Comment on lines +65 to +68
// A plain DateTime.Now default value is read only once and then shared by every picker,
// so all pickers showed the same frozen time until app restart. The creator runs once per
// picker, so each picker gets the current time instead.
defaultValueCreator: bindable => DateTime.Now);
Comment on lines +21 to +24
// A plain DateTime.Now default value is read only once and then shared by every picker,
// so all pickers showed the same frozen time until app restart. The creator runs once per
// picker, so each picker gets the current time instead.
defaultValueCreator: bindable => DateTime.Now);
Comment on lines +8 to 12
typeof(HorizontalInlineDatePicker),
defaultValue: default(DateTime),
defaultBindingMode: BindingMode.TwoWay,
propertyChanged: (b, _, _) =>
{
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