Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Date Picker with only "date" or "time" does not display correctly #2115

Merged
merged 3 commits into from
Jul 15, 2024

Conversation

iOvergaard
Copy link
Collaborator

@iOvergaard iOvergaard commented Jul 15, 2024

Description

The server always expects a regular DateTime string because the property value converter does not consider the config. The value will be unset if the string does not validate as a DateTime.

This PR aims to differentiate between input and output dates to communicate the expected value to the underlying date input component. The UI component expects the following:

Format Inner input Output
datetime-local YYYY-MM-DDTHH:mm(:ss) YYYY-MM-DD HH:mm:ss
date YYYY-MM-DD YYYY-MM-DD HH:mm:ss
time HH:mm(:ss) YYYY-MM-DD HH:mm:ss

Because of this, we have to patch the value coming out of the UI into a regular DateTime. Vice-versa we have to patch the value from the database into the expected inner input value.

Fixes umbraco/Umbraco-CMS#16779

How to test

  1. Configure a Date Picker with a format of HH:mm:ss
  2. Test that it is possible to save a value
  3. Test that the saved value is displayed correctly to the end-user
  4. Verify that the updated unit tests make sense

Screenshots

image

… send various datetime strings regardless of the configuration of the property editor, for example the "time" configuration could still be complete datetime string
@iOvergaard iOvergaard enabled auto-merge (squash) July 15, 2024 09:08
@iOvergaard iOvergaard disabled auto-merge July 15, 2024 09:21
… because the server always expects datetimes whereas the client expects differentiated strings
@iOvergaard iOvergaard enabled auto-merge (squash) July 15, 2024 12:14
@iOvergaard iOvergaard changed the title Bugfix: Date Picker with only "time" does not display correctly Bugfix: Date Picker with only "date" or "time" does not display correctly Jul 15, 2024
Copy link
Member

@leekelleher leekelleher left a comment

Choose a reason for hiding this comment

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

Tested out, works as expected! 🚀

@iOvergaard iOvergaard merged commit eec58d4 into main Jul 15, 2024
7 checks passed
@iOvergaard iOvergaard deleted the v14/bugfix/date-picker-time branch July 15, 2024 18:32
iOvergaard added a commit that referenced this pull request Jul 16, 2024
* fix: takes care of a case where the server and/or input element could send various datetime strings regardless of the configuration of the property editor, for example the "time" configuration could still be complete datetime string

* test: adds tests for all the various input and output cases to ensure the format is 100% matching

* fix: add `_inputValue` to differ between the input and output values, because the server always expects datetimes whereas the client expects differentiated strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Date Picker not saving data
2 participants