datetime type fields not respecting empty default value #853

This commit is contained in:
Elio Struyf
2024-09-23 10:02:48 +02:00
parent dc23aba128
commit 8b95468c78
5 changed files with 5 additions and 4 deletions
+1
View File
@@ -19,6 +19,7 @@
- [#842](https://github.com/estruyf/vscode-front-matter/issues/842): Allow to set the `frontMatter.taxonomy.slugTemplate` setting to an empty string
- [#845](https://github.com/estruyf/vscode-front-matter/issues/845): Fix empty values for number fields
- [#849](https://github.com/estruyf/vscode-front-matter/issues/849): Show fields which are not empty in the metadata panel
- [#853](https://github.com/estruyf/vscode-front-matter/issues/853): Allow empty values in date fields
### 🚧 Work in progress
+1 -1
View File
@@ -500,7 +500,7 @@ export class ArticleHelper {
const dateFields = contentType.fields.filter((field) => field.type === 'datetime');
for (const dateField of dateFields) {
if (typeof article?.data[dateField.name] !== 'undefined') {
if (article?.data[dateField.name]) {
article.data[dateField.name] = Article.formatDate(new Date(), dateField.dateFormat);
}
}
+1 -1
View File
@@ -73,7 +73,7 @@ const Collapsible: React.FunctionComponent<ICollapsibleProps> = ({
title={title}
onClick={triggerClick}
open={isOpen}>
<div className={`section collapsible__body ${className || ''}`}>
<div className={`section collapsible__body overflow-y-auto ${className || ''}`}>
{children}
</div>
</VSCodePane>
@@ -76,7 +76,7 @@ export const DateTimeField: React.FunctionComponent<IDateTimeFieldProps> = ({
<div className={`metadata_field__datetime`}>
<DatePicker
selected={(DateHelper.tryParse(dateValue, format) as Date) || new Date()}
selected={(DateHelper.tryParse(dateValue, format) as Date) || null}
onChange={onDateChange}
timeInputLabel={l10n.t(LocalizationKey.panelFieldsDateTimeFieldTime)}
dateFormat={DateHelper.formatUpdate(format) || DEFAULT_FORMAT}
@@ -94,7 +94,7 @@ export const WrapperField: React.FunctionComponent<IWrapperFieldProps> = ({
}
if (field.type === 'datetime') {
value = getDate(value) || undefined;
value = value ? getDate(value) : undefined;
}
if (value === undefined && field.default) {