diff --git a/CHANGELOG.md b/CHANGELOG.md index a574a4d9..2288aeef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/helpers/ArticleHelper.ts b/src/helpers/ArticleHelper.ts index 08cb735a..f133d6ab 100644 --- a/src/helpers/ArticleHelper.ts +++ b/src/helpers/ArticleHelper.ts @@ -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); } } diff --git a/src/panelWebView/components/Collapsible.tsx b/src/panelWebView/components/Collapsible.tsx index e429e557..5477e1d6 100644 --- a/src/panelWebView/components/Collapsible.tsx +++ b/src/panelWebView/components/Collapsible.tsx @@ -73,7 +73,7 @@ const Collapsible: React.FunctionComponent = ({ title={title} onClick={triggerClick} open={isOpen}> -
+
{children}
diff --git a/src/panelWebView/components/Fields/DateTimeField.tsx b/src/panelWebView/components/Fields/DateTimeField.tsx index 65d12916..9f151955 100644 --- a/src/panelWebView/components/Fields/DateTimeField.tsx +++ b/src/panelWebView/components/Fields/DateTimeField.tsx @@ -76,7 +76,7 @@ export const DateTimeField: React.FunctionComponent = ({
= ({ } if (field.type === 'datetime') { - value = getDate(value) || undefined; + value = value ? getDate(value) : undefined; } if (value === undefined && field.default) {