Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable3.7] fix: Apply recipient search input on blur #10290

Open
wants to merge 1 commit into
base: stable3.7
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 41 additions & 18 deletions src/components/Composer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<NcSelect id="to"
ref="toLabel"
:value="selectTo"
:options="selectableRecipients.filter(reciptient=>!selectTo.some(to=>to.email===reciptient.email))"
:options="selectableRecipients.filter(recipient=>!selectTo.some(to=>to.email===recipient.email))"
:taggable="true"
:aria-label-combobox="t('mail', 'Select recipient')"
:filter-by="(option, label, search)=>filterOption(option, label, search,'to')"
Expand All @@ -52,8 +52,10 @@
:clearable="true"
:no-wrap="false"
:create-option="createRecipientOption"
:clear-search-on-blur="() => clearOnBlur('to')"
@input="saveDraftDebounced"
@option:selecting="onNewToAddr"
@search:blur="onNewToAddr"
@search="onAutocomplete($event, 'to')">
<template #search="{ events, attributes }">
<input :placeholder="t('mail', 'Contact or email address …')"
Expand Down Expand Up @@ -94,12 +96,12 @@
ref="toLabel"
:value="selectCc"
:class="{'opened': !autoLimit,'select':true}"
:options="selectableRecipients.filter(reciptient=>!selectCc.some(cc=>cc.email===reciptient.email))"
:options="selectableRecipients.filter(recipient=>!selectCc.some(cc=>cc.email===recipient.email))"
:no-wrap="false"
:filter-by="(option, label, search)=>filterOption(option, label, search,'cc')"
:taggable="true"
:close-on-select="true"

:clear-search-on-blur="() => clearOnBlur('cc')"
:multiple="true"
:placeholder="t('mail', 'Contact or email address …')"
:aria-label-combobox="t('mail', 'Contact or email address …')"
Expand All @@ -110,6 +112,7 @@
:create-option="createRecipientOption"
@input="saveDraftDebounced"
@option:selecting="onNewCcAddr"
@search:blur="onNewCcAddr"
@search="onAutocomplete($event, 'cc')">
<template #search="{ events, attributes }">
<input :placeholder="t('mail', 'Contact or email address …')"
Expand Down Expand Up @@ -146,10 +149,10 @@
:class="{'opened': !autoLimit,'select':true}"
:no-wrap="false"
:filter-by="(option, label, search)=>filterOption(option, label, search,'bcc')"
:options="selectableRecipients.filter(reciptient=>!selectBcc.some(bcc=>bcc.email===reciptient.email))"
:options="selectableRecipients.filter(recipient=>!selectBcc.some(bcc=>bcc.email===recipient.email))"
:taggable="true"
:close-on-select="true"

:clear-search-on-blur="() => clearOnBlur('bcc')"
:multiple="true"
:placeholder="t('mail', 'Contact or email address …')"
:aria-label-combobox="t('mail', 'Contact or email address …')"
Expand All @@ -160,6 +163,7 @@
:create-option="createRecipientOption"
@input="saveDraftDebounced"
@option:selecting="onNewBccAddr"
@search:blur="onNewBccAddr"
@search="onAutocomplete($event, 'bcc')">
<template #search="{ events, attributes }">
<input :placeholder="t('mail', 'Contact or email address …')"
Expand Down Expand Up @@ -668,6 +672,7 @@
wantsSmimeSign: this.smimeSign,
wantsSmimeEncrypt: this.smimeEncrypt,
isPickerOpen: false,
recipientSearchTerms: {},
}
},
computed: {
Expand Down Expand Up @@ -969,6 +974,9 @@
window.removeEventListener('mailvelope', this.onMailvelopeLoaded)
},
methods: {
clearOnBlur(event) {
return this.recipientSearchTerms[event].includes('@')
},
handleShow(event) {
this.$emit('show-toolbar', event)
},
Expand Down Expand Up @@ -1174,19 +1182,20 @@
onAddCloudAttachmentLink() {
this.bus.emit('on-add-cloud-attachment-link')
},
onAutocomplete(term, loadingIndicator) {
onAutocomplete(term, addressType) {
if (term === undefined || term === '') {
return
}
this.loadingIndicatorTo = loadingIndicator === 'to'
this.loadingIndicatorCc = loadingIndicator === 'cc'
this.loadingIndicatorBcc = loadingIndicator === 'bcc'
this.loadingIndicatorTo = addressType === 'to'
this.loadingIndicatorCc = addressType === 'cc'
this.loadingIndicatorBcc = addressType === 'bcc'
this.recipientSearchTerms[addressType] = term
debouncedSearch(term).then((results) => {
if (loadingIndicator === 'to') {
if (addressType === 'to') {
this.loadingIndicatorTo = false
} else if (loadingIndicator === 'cc') {
} else if (addressType === 'cc') {
this.loadingIndicatorCc = false
} else if (loadingIndicator === 'bcc') {
} else if (addressType === 'bcc') {
this.loadingIndicatorBcc = false
}

Expand All @@ -1212,16 +1221,30 @@
await this.checkRecipientsKeys()
},
onNewToAddr(option) {
this.onNewAddr(option, this.selectTo)
this.onNewAddr(option, this.selectTo, 'to')
},
onNewCcAddr(option) {
this.onNewAddr(option, this.selectCc)
this.onNewAddr(option, this.selectCc, 'cc')
},
onNewBccAddr(option) {
this.onNewAddr(option, this.selectBcc)
},
onNewAddr(option, list) {
if (list.some((recipient) => recipient.email === option.email)) {
this.onNewAddr(option, this.selectBcc, 'bcc')
},
onNewAddr(option, list, type) {
if (
(option === null || option === undefined)
&& this.recipientSearchTerms[type] !== undefined
&& this.recipientSearchTerms[type] !== ''
) {
if (!this.recipientSearchTerms[type].includes('@')) {
return
}
option = {}
option.email = this.recipientSearchTerms[type]
option.label = this.recipientSearchTerms[type]
this.recipientSearchTerms[type] = ''
}

if (list.some((recipient) => recipient.email === option?.email) || !option) {
return
}
const recipient = { ...option }
Expand Down Expand Up @@ -1381,8 +1404,8 @@
* Empty if label and email are the same or
* if the suggestion is a group.
*
* @param {{email: string, label: string}} option

Check warning on line 1407 in src/components/Composer.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "option" description
* @return string

Check warning on line 1408 in src/components/Composer.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @return type
*/
getSubnameForRecipient(option) {
if (option.source && option.source === 'groups') {
Expand Down
Loading