Skip to content

Commit a6d0ab6

Browse files
committed
Fix pasting comma separated validation rules
1 parent 7aba8be commit a6d0ab6

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

resources/js/components/field-validation/Builder.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
multiple
3535
searchable
3636
taggable
37+
paste-delimiter="|"
3738
close-on-select
3839
:model-value="rules"
3940
@selected="add($event)"

resources/js/components/ui/Combobox/Combobox.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ const props = defineProps({
5555
options: { type: Array, default: () => [] },
5656
/** Key of the option's value in the option's object. */
5757
optionValue: { type: String, default: 'value' },
58+
/** The delimiter used to split pasted text into multiple tags. Only used when `taggable` is `true`. */
59+
pasteDelimiter: { type: String, default: ',' },
5860
placeholder: { type: String, default: () => __('Select...') },
5961
readOnly: { type: Boolean, default: false },
6062
/** When `true`, the options will be searchable. */
@@ -315,7 +317,12 @@ function onPaste(e) {
315317
316318
const pastedValue = e.clipboardData.getData('text');
317319
318-
updateModelValue([...(props.modelValue ?? []), ...pastedValue.split(',').map((v) => v.trim())]);
320+
const tags = pastedValue
321+
.split(props.pasteDelimiter)
322+
.map((v) => v.trim())
323+
.filter((v) => v !== '');
324+
325+
updateModelValue([...(props.modelValue ?? []), ...tags]);
319326
}
320327
321328
function pushTaggableOption(e) {

0 commit comments

Comments
 (0)