Skip to content

Commit 11f85c6

Browse files
author
Sean Wilson
committed
fix array adding item anyOf infinite loop
1 parent 9c63b9a commit 11f85c6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/lib/Control.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
: useAnyOf(schema) ? "anyOf"
2727
: schema?.type;
2828
const singleType = (Array.isArray(type) ? type[0] : type) ?? "object";
29-
control = controls[singleType as keyof typeof controls] as any;
29+
const updatedControl = controls[singleType as keyof typeof controls] as any;
30+
if (updatedControl != control) {
31+
control = updatedControl;
32+
}
3033
}
3134
</script>
3235

src/lib/controls/AnyOfControl.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import type { JSONSchema7, JSONSchema7Definition } from "json-schema";
33
import type UISchema from "$lib/UISchema";
44
import deepEquals from "fast-deep-equal";
5-
import { isObjectSchema, omit, getLabel } from "$lib/utilities";
5+
import { isObjectSchema, omit, getLabel, isEmpty } from "$lib/utilities";
66
import Paper, { Title, Content } from "@smui/paper";
77
import Select, { Option } from '@smui/select';
88
import Control from "../Control.svelte";
@@ -59,7 +59,8 @@
5959
data = omitted;
6060
}
6161
}
62-
else {
62+
else if ((data == null) || !isEmpty(data)) {
63+
await tick();
6364
data = {};
6465
}
6566
selectedProps = Object.keys(selected?.properties ?? {})

0 commit comments

Comments
 (0)