Fix datetime string handler not matching default value for format option (#19168)

* Default format to `long` to match display value

Fixes #19152

* Add changeset
This commit is contained in:
Rijk van Zanten
2023-07-14 21:11:30 +02:00
committed by GitHub
parent d6e0e35970
commit e6db6f70f5
2 changed files with 9 additions and 3 deletions

View File

@@ -0,0 +1,6 @@
---
'@directus/app': patch
---
Fixed an issue that would prevent the "Download Page as CSV" option to function when using a datetime display with
missing options

View File

@@ -35,16 +35,16 @@ export default defineDisplay({
} else {
let format;
if (options?.format === 'long') {
if (options?.format === undefined || options.format === 'long') {
format = `${i18n.global.t('date-fns_date')} ${i18n.global.t('date-fns_time')}`;
if (field?.type === 'date') format = String(i18n.global.t('date-fns_date'));
if (field?.type === 'time') format = String(i18n.global.t('date-fns_time'));
} else if (options?.format === 'short') {
} else if (options.format === 'short') {
format = `${i18n.global.t('date-fns_date_short')} ${i18n.global.t('date-fns_time_short')}`;
if (field?.type === 'date') format = String(i18n.global.t('date-fns_date_short'));
if (field?.type === 'time') format = String(i18n.global.t('date-fns_time_short'));
} else {
format = options?.format;
format = options.format;
}
return localizedFormat(value, format);