mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-07 01:13:08 +02:00
datetime type fields not respecting empty default value #853
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user