Fix : Dataviews date misalignment#75611
Conversation
|
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. |
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @JanaMW27. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
| __next40pxDefaultSize | ||
| ref={ validityTargetRef } | ||
| type="date" | ||
| type="text" |
There was a problem hiding this comment.
This alone breaks so many things like validation, a11y etc..
Below we don't use the getValueFormatted which also breaks formatting.
Thanks for the PR, but it's not the right approach. We need to explore alternatives, although I'm not even sure how we could match a native date input (that is needed) with custom formatting we use for displaying the values..
What?
type="date"inputs totype="text"inputs with locale-aware formatting and placeholders.Why?
Native
type="date"inputs display dates in a browser-specific format (typicallyyyyy-mm-dd) . Users expect to see dates formatted according to their locale settings (e.g.,dd/mm/yyyyin Europe,mm/dd/yyyyin the US). This change provides:dd/mm/yyyyormm/dd/yyyy)How?
Changes made:
dataviews-filters/utils.ts:formatDateValue(value: string)- Formats an ISO date string (yyyy-mm-dd) to a locale-aware display string usingtoLocaleDateString()getDatePlaceholder()- Generates a locale-aware placeholder string (e.g.,dd/mm/yyyy,mm/dd/yyyy) usingIntl.DateTimeFormatdataform-controls/date.tsx:InputControltype from"date"to"text"for both single date and date range inputsplaceholderprop usinggetDatePlaceholder()formatDateValue()to display dates in the input valuedataviews-filters/filter.tsx:formatDateValueutilityTesting Instructions
dd/mm/yyyyfor UK,mm/dd/yyyyfor US).yyyy-mm-dd.