Skip to content

Commit

Permalink
Ensure ArrayField value is always an array
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Dec 4, 2023
1 parent fee57e5 commit 5347a6d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions src/addons/dispatch/fields/ArrayField.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script lang="ts">
import { beforeUpdate } from "svelte";
import Plus16 from "svelte-octicons/lib/Plus16.svelte";
import Checkbox from "./Checkbox.svelte";
import X16 from "svelte-octicons/lib/X16.svelte";
import Number from "./Number.svelte";
Expand All @@ -15,9 +17,16 @@
};
export let count: number = 1;
export let value = Array(count).fill(null);
export let value: [any] = Array(count).fill(null);
$: numItems = value?.length ?? 0;
$: numItems = value.length;
beforeUpdate(() => {
// value should always be an array
if (!Array.isArray(value)) {
value = [];
}
});
// only one level of nesting allowed
const types = {
Expand Down

0 comments on commit 5347a6d

Please sign in to comment.