Skip to content

Commit 7b489f2

Browse files
Merge pull request #10290 from nextcloud/backport/9566/stable3.7-2
[stable3.7] fix: Apply recipient search input on blur
2 parents 858c9ba + bafacf7 commit 7b489f2

1 file changed

Lines changed: 41 additions & 18 deletions

File tree

src/components/Composer.vue

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<NcSelect id="to"
4141
ref="toLabel"
4242
:value="selectTo"
43-
:options="selectableRecipients.filter(reciptient=>!selectTo.some(to=>to.email===reciptient.email))"
43+
:options="selectableRecipients.filter(recipient=>!selectTo.some(to=>to.email===recipient.email))"
4444
:taggable="true"
4545
:aria-label-combobox="t('mail', 'Select recipient')"
4646
:filter-by="(option, label, search)=>filterOption(option, label, search,'to')"
@@ -52,8 +52,10 @@
5252
:clearable="true"
5353
:no-wrap="false"
5454
:create-option="createRecipientOption"
55+
:clear-search-on-blur="() => clearOnBlur('to')"
5556
@input="saveDraftDebounced"
5657
@option:selecting="onNewToAddr"
58+
@search:blur="onNewToAddr"
5759
@search="onAutocomplete($event, 'to')">
5860
<template #search="{ events, attributes }">
5961
<input :placeholder="t('mail', 'Contact or email address …')"
@@ -94,12 +96,12 @@
9496
ref="toLabel"
9597
:value="selectCc"
9698
:class="{'opened': !autoLimit,'select':true}"
97-
:options="selectableRecipients.filter(reciptient=>!selectCc.some(cc=>cc.email===reciptient.email))"
99+
:options="selectableRecipients.filter(recipient=>!selectCc.some(cc=>cc.email===recipient.email))"
98100
:no-wrap="false"
99101
:filter-by="(option, label, search)=>filterOption(option, label, search,'cc')"
100102
:taggable="true"
101103
:close-on-select="true"
102-
104+
:clear-search-on-blur="() => clearOnBlur('cc')"
103105
:multiple="true"
104106
:placeholder="t('mail', 'Contact or email address …')"
105107
:aria-label-combobox="t('mail', 'Contact or email address …')"
@@ -110,6 +112,7 @@
110112
:create-option="createRecipientOption"
111113
@input="saveDraftDebounced"
112114
@option:selecting="onNewCcAddr"
115+
@search:blur="onNewCcAddr"
113116
@search="onAutocomplete($event, 'cc')">
114117
<template #search="{ events, attributes }">
115118
<input :placeholder="t('mail', 'Contact or email address …')"
@@ -146,10 +149,10 @@
146149
:class="{'opened': !autoLimit,'select':true}"
147150
:no-wrap="false"
148151
:filter-by="(option, label, search)=>filterOption(option, label, search,'bcc')"
149-
:options="selectableRecipients.filter(reciptient=>!selectBcc.some(bcc=>bcc.email===reciptient.email))"
152+
:options="selectableRecipients.filter(recipient=>!selectBcc.some(bcc=>bcc.email===recipient.email))"
150153
:taggable="true"
151154
:close-on-select="true"
152-
155+
:clear-search-on-blur="() => clearOnBlur('bcc')"
153156
:multiple="true"
154157
:placeholder="t('mail', 'Contact or email address …')"
155158
:aria-label-combobox="t('mail', 'Contact or email address …')"
@@ -160,6 +163,7 @@
160163
:create-option="createRecipientOption"
161164
@input="saveDraftDebounced"
162165
@option:selecting="onNewBccAddr"
166+
@search:blur="onNewBccAddr"
163167
@search="onAutocomplete($event, 'bcc')">
164168
<template #search="{ events, attributes }">
165169
<input :placeholder="t('mail', 'Contact or email address …')"
@@ -668,6 +672,7 @@ export default {
668672
wantsSmimeSign: this.smimeSign,
669673
wantsSmimeEncrypt: this.smimeEncrypt,
670674
isPickerOpen: false,
675+
recipientSearchTerms: {},
671676
}
672677
},
673678
computed: {
@@ -969,6 +974,9 @@ export default {
969974
window.removeEventListener('mailvelope', this.onMailvelopeLoaded)
970975
},
971976
methods: {
977+
clearOnBlur(event) {
978+
return this.recipientSearchTerms[event].includes('@')
979+
},
972980
handleShow(event) {
973981
this.$emit('show-toolbar', event)
974982
},
@@ -1174,19 +1182,20 @@ export default {
11741182
onAddCloudAttachmentLink() {
11751183
this.bus.emit('on-add-cloud-attachment-link')
11761184
},
1177-
onAutocomplete(term, loadingIndicator) {
1185+
onAutocomplete(term, addressType) {
11781186
if (term === undefined || term === '') {
11791187
return
11801188
}
1181-
this.loadingIndicatorTo = loadingIndicator === 'to'
1182-
this.loadingIndicatorCc = loadingIndicator === 'cc'
1183-
this.loadingIndicatorBcc = loadingIndicator === 'bcc'
1189+
this.loadingIndicatorTo = addressType === 'to'
1190+
this.loadingIndicatorCc = addressType === 'cc'
1191+
this.loadingIndicatorBcc = addressType === 'bcc'
1192+
this.recipientSearchTerms[addressType] = term
11841193
debouncedSearch(term).then((results) => {
1185-
if (loadingIndicator === 'to') {
1194+
if (addressType === 'to') {
11861195
this.loadingIndicatorTo = false
1187-
} else if (loadingIndicator === 'cc') {
1196+
} else if (addressType === 'cc') {
11881197
this.loadingIndicatorCc = false
1189-
} else if (loadingIndicator === 'bcc') {
1198+
} else if (addressType === 'bcc') {
11901199
this.loadingIndicatorBcc = false
11911200
}
11921201
@@ -1212,16 +1221,30 @@ export default {
12121221
await this.checkRecipientsKeys()
12131222
},
12141223
onNewToAddr(option) {
1215-
this.onNewAddr(option, this.selectTo)
1224+
this.onNewAddr(option, this.selectTo, 'to')
12161225
},
12171226
onNewCcAddr(option) {
1218-
this.onNewAddr(option, this.selectCc)
1227+
this.onNewAddr(option, this.selectCc, 'cc')
12191228
},
12201229
onNewBccAddr(option) {
1221-
this.onNewAddr(option, this.selectBcc)
1222-
},
1223-
onNewAddr(option, list) {
1224-
if (list.some((recipient) => recipient.email === option.email)) {
1230+
this.onNewAddr(option, this.selectBcc, 'bcc')
1231+
},
1232+
onNewAddr(option, list, type) {
1233+
if (
1234+
(option === null || option === undefined)
1235+
&& this.recipientSearchTerms[type] !== undefined
1236+
&& this.recipientSearchTerms[type] !== ''
1237+
) {
1238+
if (!this.recipientSearchTerms[type].includes('@')) {
1239+
return
1240+
}
1241+
option = {}
1242+
option.email = this.recipientSearchTerms[type]
1243+
option.label = this.recipientSearchTerms[type]
1244+
this.recipientSearchTerms[type] = ''
1245+
}
1246+
1247+
if (list.some((recipient) => recipient.email === option?.email) || !option) {
12251248
return
12261249
}
12271250
const recipient = { ...option }

0 commit comments

Comments
 (0)