Skip to content

Commit

Permalink
#845 - Fix empty values for number fields
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Sep 5, 2024
1 parent 8cc68be commit 3f8665c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

### 🐞 Fixes

- [#845](https://github.com/estruyf/vscode-front-matter/issues/845): Fix empty values for number fields

## [10.3.0] - 2024-08-13 - [Release notes](https://beta.frontmatter.codes/updates/v10.3.0)

### ✨ New features
Expand Down
2 changes: 2 additions & 0 deletions src/listeners/panel/DataListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ export class DataListener extends BaseListener {
if (!sourceField.default) {
value = undefined;
}
} else if (sourceField?.type === 'number') {
// We don't have to do anything for numbers, we can leave the 0 value
} else {
value = undefined;
}
Expand Down
6 changes: 5 additions & 1 deletion src/panelWebView/components/Fields/WrapperField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ export const WrapperField: React.FunctionComponent<IWrapperFieldProps> = ({
} else {
// Did not contain a placeholder, so value can be set
if (fieldValue === undefined || value !== fieldValue) {
setFieldValue(value || null);
if (typeof value === 'number') {
setFieldValue(value);
} else {
setFieldValue(value || null);
}
}
}
}, [field, parent]);
Expand Down

0 comments on commit 3f8665c

Please sign in to comment.