Skip to content

Commit

Permalink
#596 - Fix for number field in block data
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Jun 30, 2023
1 parent a041d82 commit 3ec532e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- [#577](https://github.com/estruyf/vscode-front-matter/issues/577): Fix in the `dataFile` field where data entries get overwritten
- [#590](https://github.com/estruyf/vscode-front-matter/issues/590): Fix for image fields inside a sub-block
- [#595](https://github.com/estruyf/vscode-front-matter/issues/595): Fix for media metadata now showing up
- [#596](https://github.com/estruyf/vscode-front-matter/issues/596): Fix for number field in block data

## [8.4.0] - 2023-04-03 - [Release notes](https://beta.frontmatter.codes/updates/v8.4.0)

Expand Down
2 changes: 1 addition & 1 deletion src/panelWebView/components/DataBlock/DataBlockField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export const DataBlockField: React.FunctionComponent<IDataBlockFieldProps> = ({
</div>
</div>
) : (
<button title={`Add ${field.name}`} onClick={onShowForm}>
<button title={`Add ${field.name} `} onClick={onShowForm}>
Add {field.name}
</button>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/panelWebView/components/Fields/NumberField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ export const NumberField: React.FunctionComponent<INumberFieldProps> = ({
}: React.PropsWithChildren<INumberFieldProps>) => {
const [nrValue, setNrValue] = React.useState<number | null>(value);

const onValueChange = useCallback((txtValue: string) => {
const onValueChange = (txtValue: string) => {
let newValue: number | null = options?.isDecimal ? parseFloat(txtValue) : parseInt(txtValue);
if (isNaN(newValue)) {
newValue = null;
}

setNrValue(newValue);
onChange(newValue);
}, [options?.isDecimal]);
};

const showRequiredState = useMemo(() => {
return required && (nrValue === null || nrValue === undefined);
Expand Down
2 changes: 1 addition & 1 deletion src/panelWebView/components/Fields/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const TextField: React.FunctionComponent<ITextFieldProps> = ({
onChange,
required
}: React.PropsWithChildren<ITextFieldProps>) => {
const [requiredFields, setRequiredFields] = useRecoilState(RequiredFieldsAtom);
const [, setRequiredFields] = useRecoilState(RequiredFieldsAtom);
const [text, setText] = React.useState<string | null>(value);

const onTextChange = (txtValue: string) => {
Expand Down
1 change: 0 additions & 1 deletion src/panelWebView/components/Fields/WrapperField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ export const WrapperField: React.FunctionComponent<IWrapperFieldProps> = ({
return (
<FieldBoundary key={field.name} fieldName={field.title || field.name}>
<NumberField
key={field.name}
label={field.title || field.name}
description={field.description}
options={field.numberOptions}
Expand Down

0 comments on commit 3ec532e

Please sign in to comment.