@@ -165,16 +165,9 @@ export const VCombobox = genericComponent<new <
165165 }
166166
167167 if ( val && props . multiple && props . delimiters ?. length ) {
168- const signsToMatch = props . delimiters . map ( escapeForRegex ) . join ( '|' )
169- const values = val . split ( new RegExp ( `(?:${ signsToMatch } )+` ) )
168+ const values = splitByDelimiters ( val )
170169 if ( values . length > 1 ) {
171- for ( let v of values ) {
172- v = v . trim ( )
173- if ( v ) {
174- select ( transformItem ( props , v ) )
175- await nextTick ( )
176- }
177- }
170+ selectMultiple ( values )
178171 _search . value = ''
179172 }
180173 }
@@ -364,6 +357,15 @@ export const VCombobox = genericComponent<new <
364357 selectionIndex . value = - 1
365358 }
366359 }
360+ function onPaste ( e : ClipboardEvent ) {
361+ const clipboardText = e ?. clipboardData ?. getData ( 'Text' ) ?? ''
362+ const values = splitByDelimiters ( clipboardText )
363+
364+ if ( values . length > 1 && props . multiple ) {
365+ e . preventDefault ( )
366+ selectMultiple ( values )
367+ }
368+ }
367369 function onAfterEnter ( ) {
368370 if ( props . eager ) {
369371 vVirtualScrollRef . value ?. calculateVisibleItems ( )
@@ -410,7 +412,20 @@ export const VCombobox = genericComponent<new <
410412 } )
411413 }
412414 }
413-
415+ function splitByDelimiters ( val : string ) {
416+ const effectiveDelimiters = [ '\n' , ...props . delimiters ?? [ ] ]
417+ const signsToMatch = effectiveDelimiters . map ( escapeForRegex ) . join ( '|' )
418+ return val . split ( new RegExp ( `(?:${ signsToMatch } )+` ) )
419+ }
420+ async function selectMultiple ( values : string [ ] ) {
421+ for ( let value of values ) {
422+ value = value . trim ( )
423+ if ( value ) {
424+ select ( transformItem ( props , value ) )
425+ await nextTick ( )
426+ }
427+ }
428+ }
414429 function onFocusin ( e : FocusEvent ) {
415430 isFocused . value = true
416431 setTimeout ( ( ) => {
@@ -500,6 +515,7 @@ export const VCombobox = genericComponent<new <
500515 onClick :clear = { onClear }
501516 onMousedown :control = { onMousedownControl }
502517 onKeydown = { onKeydown }
518+ onPaste = { onPaste }
503519 aria-expanded = { ariaExpanded . value }
504520 aria-controls = { ariaControls . value }
505521 >
0 commit comments