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')"
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 …')"
9597 ref =" toLabel"
9698 :value =" selectCc"
9799 :class =" {'opened': !autoLimit,'select':true}"
98- :options =" selectableRecipients.filter(reciptient =>!selectCc.some(cc=>cc.email===reciptient .email))"
100+ :options =" selectableRecipients.filter(recipient =>!selectCc.some(cc=>cc.email===recipient .email))"
99101 :no-wrap =" false"
100102 :filter-by =" (option, label, search)=>filterOption(option, label, search,'cc')"
101103 :taggable =" true"
102104 :close-on-select =" true"
103-
105+ :clear-search-on-blur = " () => clearOnBlur('cc') "
104106 :multiple =" true"
105107 :placeholder =" t('mail', 'Contact or email address …')"
106108 :aria-label-combobox =" t('mail', 'Contact or email address …')"
111113 :create-option =" createRecipientOption"
112114 @input =" saveDraftDebounced"
113115 @option:selecting =" onNewCcAddr"
116+ @search:blur =" onNewCcAddr"
114117 @search =" onAutocomplete($event, 'cc')" >
115118 <template #search =" { events , attributes } " >
116119 <input :placeholder =" t('mail', 'Contact or email address …')"
148151 :class =" {'opened': !autoLimit,'select':true}"
149152 :no-wrap =" false"
150153 :filter-by =" (option, label, search)=>filterOption(option, label, search,'bcc')"
151- :options =" selectableRecipients.filter(reciptient =>!selectBcc.some(bcc=>bcc.email===reciptient .email))"
154+ :options =" selectableRecipients.filter(recipient =>!selectBcc.some(bcc=>bcc.email===recipient .email))"
152155 :taggable =" true"
153156 :close-on-select =" true"
154-
157+ :clear-search-on-blur = " () => clearOnBlur('bcc') "
155158 :multiple =" true"
156159 :placeholder =" t('mail', 'Contact or email address …')"
157160 :aria-label-combobox =" t('mail', 'Contact or email address …')"
162165 :create-option =" createRecipientOption"
163166 @input =" saveDraftDebounced"
164167 @option:selecting =" onNewBccAddr"
168+ @search:blur =" onNewBccAddr"
165169 @search =" onAutocomplete($event, 'bcc')" >
166170 <template #search =" { events , attributes } " >
167171 <input :placeholder =" t('mail', 'Contact or email address …')"
@@ -671,6 +675,7 @@ export default {
671675 wantsSmimeSign: this .smimeSign ,
672676 wantsSmimeEncrypt: this .smimeEncrypt ,
673677 isPickerOpen: false ,
678+ recipientSearchTerms: {},
674679 }
675680 },
676681 computed: {
@@ -972,6 +977,9 @@ export default {
972977 window .removeEventListener (' mailvelope' , this .onMailvelopeLoaded )
973978 },
974979 methods: {
980+ clearOnBlur (event ) {
981+ return this .recipientSearchTerms [event ].includes (' @' )
982+ },
975983 handleShow (event ) {
976984 this .$emit (' show-toolbar' , event )
977985 },
@@ -1177,19 +1185,20 @@ export default {
11771185 onAddCloudAttachmentLink () {
11781186 this .bus .emit (' on-add-cloud-attachment-link' )
11791187 },
1180- onAutocomplete (term , loadingIndicator ) {
1188+ onAutocomplete (term , addressType ) {
11811189 if (term === undefined || term === ' ' ) {
11821190 return
11831191 }
1184- this .loadingIndicatorTo = loadingIndicator === ' to'
1185- this .loadingIndicatorCc = loadingIndicator === ' cc'
1186- this .loadingIndicatorBcc = loadingIndicator === ' bcc'
1192+ this .loadingIndicatorTo = addressType === ' to'
1193+ this .loadingIndicatorCc = addressType === ' cc'
1194+ this .loadingIndicatorBcc = addressType === ' bcc'
1195+ this .recipientSearchTerms [addressType] = term
11871196 debouncedSearch (term).then ((results ) => {
1188- if (loadingIndicator === ' to' ) {
1197+ if (addressType === ' to' ) {
11891198 this .loadingIndicatorTo = false
1190- } else if (loadingIndicator === ' cc' ) {
1199+ } else if (addressType === ' cc' ) {
11911200 this .loadingIndicatorCc = false
1192- } else if (loadingIndicator === ' bcc' ) {
1201+ } else if (addressType === ' bcc' ) {
11931202 this .loadingIndicatorBcc = false
11941203 }
11951204
@@ -1215,16 +1224,30 @@ export default {
12151224 await this .checkRecipientsKeys ()
12161225 },
12171226 onNewToAddr (option ) {
1218- this .onNewAddr (option, this .selectTo )
1227+ this .onNewAddr (option, this .selectTo , ' to ' )
12191228 },
12201229 onNewCcAddr (option ) {
1221- this .onNewAddr (option, this .selectCc )
1230+ this .onNewAddr (option, this .selectCc , ' cc ' )
12221231 },
12231232 onNewBccAddr (option ) {
1224- this .onNewAddr (option, this .selectBcc )
1225- },
1226- onNewAddr (option , list ) {
1227- if (list .some ((recipient ) => recipient .email === option .email )) {
1233+ this .onNewAddr (option, this .selectBcc , ' bcc' )
1234+ },
1235+ onNewAddr (option , list , type ) {
1236+ if (
1237+ (option === null || option === undefined )
1238+ && this .recipientSearchTerms [type] !== undefined
1239+ && this .recipientSearchTerms [type] !== ' '
1240+ ) {
1241+ if (! this .recipientSearchTerms [type].includes (' @' )) {
1242+ return
1243+ }
1244+ option = {}
1245+ option .email = this .recipientSearchTerms [type]
1246+ option .label = this .recipientSearchTerms [type]
1247+ this .recipientSearchTerms [type] = ' '
1248+ }
1249+
1250+ if (list .some ((recipient ) => recipient .email === option? .email ) || ! option) {
12281251 return
12291252 }
12301253 const recipient = { ... option }
0 commit comments