Skip to content

Commit a9a5bc8

Browse files
committed
docs: fix object chips input demo not working when all chips removed
Closes #704
1 parent 6f6544e commit a9a5bc8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/site/src/routes/demo/chip-input/_AutocompleteObjects.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
4040
// And we can push our own object containing the text.
4141
colors.push({
42-
id: Math.max(...colors.map((color) => color.id)) + 1,
42+
id: colors.length ? Math.max(...colors.map((color) => color.id)) + 1 : 1,
4343
text: event.detail.text,
4444
});
4545
value = '';
@@ -51,7 +51,7 @@
5151
5252
// And we can push our own object containing the text.
5353
colors.push({
54-
id: Math.max(...colors.map((color) => color.id)) + 1,
54+
id: colors.length ? Math.max(...colors.map((color) => color.id)) + 1 : 1,
5555
text: event.detail,
5656
});
5757
value = '';

packages/site/src/routes/demo/chip-input/_Objects.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
3838
// And we can push our own object containing the text.
3939
items.push({
40-
id: Math.max(...items.map((tag) => tag.id)) + 1,
40+
id: items.length ? Math.max(...items.map((tag) => tag.id)) + 1 : 1,
4141
text: event.detail.text,
4242
});
4343
value = '';

0 commit comments

Comments
 (0)