Skip to content

Commit

Permalink
Bug fixes on the different field types handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Michaël St-Georges committed Mar 12, 2024
1 parent f7da500 commit 9f7a7a3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "json-editor",
"version": "1.1.0",
"version": "1.1.1",
"description": "JSON Editor (based on https://github.com/josdejong/svelte-jsoneditor)",
"license": "MIT",
"svelte": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"key": "fieldType",
"label": "Field Type",
"options": [{"label": "String", "value": "text"}, {"label": "JSON", "value": "json"}],
"defaultValue": "String",
"defaultValue": "text",
"required": true
},
{
Expand Down
7 changes: 3 additions & 4 deletions src/Component.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
}
if (fieldType !== 'text' && fieldType !== 'json') {
console.log(fieldText, fieldJSON);
configErrors = configErrors + "Select a field type\n";
}
Expand Down Expand Up @@ -59,18 +58,18 @@
$: formStep = formStepContext ? $formStepContext || 1 : 1;
$: labelClass = labelPos === "above" ? "" : `spectrum-FieldLabel--${labelPos}`;
$: if (formApi && (fieldText || fieldJSON)) {
$: if (formApi && (fieldText || fieldJSON) && !configErrors) {
const formField = formApi.registerField(
getField(),
fieldType,
defaultValue,
false,
readOnly,
validationText,
formStep
);
unsubscribe = formField.subscribe((value) => {
unsubscribe = formField?.subscribe((value) => {
fieldState = value?.fieldState;
fieldApi = value?.fieldApi;
});
Expand Down

0 comments on commit 9f7a7a3

Please sign in to comment.