-
Notifications
You must be signed in to change notification settings - Fork 82
fix(date, date-range): ensure date format override returns correct formatted value #7359
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like James was correct here and we should be generating the list of formats to match from the override string and not from the locale format, which is what was causing the mismatch when day and month values were swapped.
"de-DE": de, | ||
}; | ||
|
||
export const I18NStory = ({ locale, ...args }: DateInputI80NProps) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: nice idea using Storybook Controls to change the locale for testing 👍
src/components/date/__internal__/date-formats/date-formats.test.ts
Outdated
Show resolved
Hide resolved
…rmatted value When overridding the default date format, the format was not always respected and would switch to the default in some cases where the day and month were flipped. fix #7345
🎉 This PR is included in version 154.7.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
fix #7345
Proposed behaviour
dateFormatOverride
prop and translation key can be used, with the prop taking precedence.Screen.Recording.2025-06-02.at.16.57.54.mov
Current behaviour
dateFormatOverride
prop has no effect.dateFormatOverride
translation key, it fails to format values correctly and parse correct raw value for theonChange
event, specially when the day and month are flipped.Using de-DE locale:
Screen.Recording.2025-06-02.at.16.50.50.mov
Checklist
d.ts
file added or updated if requiredQA
Additional context
Testing instructions
i18n Story
test story in storybook and changing thedateFormatOverride
, see actions for returned formatted and raw values.03-06-2019
should update to03/06/2019
if date format isdd/MM/yyyy
.