Skip to content

Commit

Permalink
[4.x] Support paste events in Taggable Fieldtype (#8903)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean authored Nov 1, 2023
1 parent c26ee82 commit b6f37d3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion resources/js/components/fieldtypes/TagsFieldtype.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
@search:focus="$emit('focus')"
@search:blur="$emit('blur')">
<template #selected-option-container><i class="hidden"></i></template>
<template #search="{ events, attributes }" v-if="config.multiple">
<template #search="{ events, attributes }">
<input
:placeholder="config.placeholder"
class="vs__search"
type="search"
v-on="events"
v-bind="attributes"
@paste="onPaste"
>
</template>
<template #no-options>
Expand Down Expand Up @@ -72,6 +73,14 @@ export default {
focus() {
this.$refs.input.focus();
},
onPaste(event) {
const pastedValue = event.clipboardData.getData('text');
this.update([...this.value, ...pastedValue.split(',')]);
event.preventDefault();
},
},
};
Expand Down

0 comments on commit b6f37d3

Please sign in to comment.