chore: update CHANGELOG for version 10.11.0 and add fix for number fields in front matter

refactor: improve empty field handling in DataListener and DataBlockField components
This commit is contained in:
Elio Struyf
2026-05-14 11:11:59 +02:00
parent 34ac4952e0
commit 1b5909b706
3 changed files with 17 additions and 2 deletions
+4
View File
@@ -6,6 +6,10 @@
- [#1030](https://github.com/estruyf/vscode-front-matter/pull/1030): Add `frontMatter.file.slugSeparator` setting
### 🐞 Fixes
- Fix number fields not being saved to front matter when used inside block field groups
## [10.10.1] - 2026-04-23
### 🐞 Fixes
+5 -1
View File
@@ -479,7 +479,11 @@ export class DataListener extends BaseListener {
const contentType = await ArticleHelper.getContentType(article);
const sourceField = ContentType.findFieldByName(contentType.fields, field);
if (!value && field !== titleField && contentType.clearEmpty) {
if (
(value === undefined || value === null || value === '' || value === false) &&
field !== titleField &&
contentType.clearEmpty
) {
// Check if the draft or boolean field needs to be cleared
// This is only required when the default value is not set to true
if (sourceField && (sourceField.type === 'draft' || sourceField.type === 'boolean')) {
@@ -98,7 +98,14 @@ export const DataBlockField: React.FunctionComponent<IDataBlockFieldProps> = ({
// Remove the empty fields
Object.keys(data).forEach((key) => {
if (data[key] === undefined || data[key] === null || Object.keys(data[key]).length === 0) {
const currentValue = data[key];
const isObjectValue =
typeof currentValue === 'object' && currentValue !== null;
const isEmptyArray = Array.isArray(currentValue) && currentValue.length === 0;
const isEmptyObject =
isObjectValue && !Array.isArray(currentValue) && Object.keys(currentValue).length === 0;
if (currentValue === undefined || currentValue === null || isEmptyArray || isEmptyObject) {
delete data[key];
}
});