Skip to content
Draft
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions src/components/Composer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
:taggable="true"
:aria-label-combobox="t('mail', 'Select recipient')"
:filter-by="(option, label, search) => filterOption(option, label, search, 'to')"
:dropdown-should-open="shouldOpenRecipientDropdown"
:multiple="true"
:clear-search-on-select="true"
:loading="loadingIndicatorTo"
Expand Down Expand Up @@ -112,6 +113,7 @@
:get-option-key="(option) => option.email"
:no-wrap="false"
:filter-by="(option, label, search) => filterOption(option, label, search, 'cc')"
:dropdown-should-open="shouldOpenRecipientDropdown"
:taggable="true"
:clear-search-on-blur="() => clearOnBlur('cc')"
:append-to-body="false"
Expand Down Expand Up @@ -169,6 +171,7 @@
:filter-by="(option, label, search) => filterOption(option, label, search, 'bcc')"
:options="selectableRecipients.filter(recipient => !selectBcc.some(bcc => bcc.email === recipient.email))"
:get-option-key="(option) => option.email"
:dropdown-should-open="shouldOpenRecipientDropdown"
:taggable="true"
:clear-search-on-blur="() => clearOnBlur('bcc')"
:append-to-body="false"
Expand Down Expand Up @@ -1172,6 +1175,10 @@ export default {
|| (option?.email || '').toLocaleLowerCase().includes(searchInLowerCase)
},

shouldOpenRecipientDropdown({ noDrop, open, search }) {
return !noDrop && open && search.trim() !== ''
},

setAlias() {
const previous = this.selectedAlias
if (this.fromAccount && this.fromAlias) {
Expand Down
54 changes: 54 additions & 0 deletions src/tests/unit/components/Composer.vue.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,58 @@ describe('Composer', () => {

expect(view.vm.submitButtonTitle).toEqual('Encrypt with Mailvelope and send later Jan 1, 02:00 PM')
})

it('does not open the recipient dropdown on focus without a search term', () => {
const view = shallowMount(Composer, {
propsData: {
isFirstOpen: true,
accounts: [
{
id: 123,
editorMode: 'plaintext',
isUnified: false,
aliases: [],
},
],
},
mocks: {
$route,
},
store,
localVue,
})

expect(view.vm.shouldOpenRecipientDropdown({
noDrop: false,
open: true,
search: '',
})).toEqual(false)
})

it('opens the recipient dropdown once a search term is entered', () => {
const view = shallowMount(Composer, {
propsData: {
isFirstOpen: true,
accounts: [
{
id: 123,
editorMode: 'plaintext',
isUnified: false,
aliases: [],
},
],
},
mocks: {
$route,
},
store,
localVue,
})

expect(view.vm.shouldOpenRecipientDropdown({
noDrop: false,
open: true,
search: 'alice',
})).toEqual(true)
})
})