Skip to content

Commit 1321a74

Browse files
marshallwpmrin9
authored andcommitted
fixed afterPaste to combine new and old values
When pasting values into a populated array field, the new values (whether one or many) will now be concatenated onto the old values.
1 parent 50d8e2a commit 1321a74

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/components/tag-input.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,16 @@ export default class TagInput extends LitElement {
3838
afterPaste(e) {
3939
const clipboardData = e.clipboardData || window.clipboardData;
4040
const pastedData = clipboardData.getData('Text');
41-
this.value = pastedData ? pastedData.split(',').filter((v) => v.trim() !== '') : '';
41+
const pastedArray = pastedData ? pastedData.split(',').filter((v) => v.trim() !== '') : '';
42+
43+
if(pastedArray) {
44+
if (Array.isArray(this.value)) {
45+
this.value = [...this.value, ...pastedArray];
46+
}
47+
else {
48+
this.value = pastedArray;
49+
}
50+
}
4251
e.preventDefault();
4352
}
4453

0 commit comments

Comments
 (0)