Skip to content

Commit 8d41299

Browse files
committed
feat(PrimeAutoComplete): enhance paste handling to support direct value assignment when no separators are provided
1 parent b5a8487 commit 8d41299

File tree

2 files changed

+67
-33
lines changed

2 files changed

+67
-33
lines changed

pnpm-lock.yaml

Lines changed: 55 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/PrimeAutoComplete.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ function handlePaste(event: ClipboardEvent) {
9494
? props.context.separators
9595
: [',']
9696
const regex = new RegExp(`[${separators.map(s => s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')).join('')}]`)
97+
// If separators are provided, split the pasted text by them
9798
if (pastedText && regex.test(pastedText)) {
9899
event.preventDefault()
99100
const items = pastedText
@@ -108,6 +109,17 @@ function handlePaste(event: ClipboardEvent) {
108109
localValue.value = items
109110
}
110111
}
112+
// If no separators, just set the value directly
113+
else if (pastedText) {
114+
event.preventDefault()
115+
// If no separators, just set the value directly
116+
if (Array.isArray(localValue.value)) {
117+
localValue.value = [...localValue.value, pastedText.trim()]
118+
}
119+
else {
120+
localValue.value = [pastedText.trim()]
121+
}
122+
}
111123
}
112124
</script>
113125

0 commit comments

Comments
 (0)