diff --git a/static/js/emailInbox.js b/static/js/emailInbox.js index b07469316..5327a46e7 100644 --- a/static/js/emailInbox.js +++ b/static/js/emailInbox.js @@ -22,8 +22,8 @@ const _replyIcon = ' `${svg}`; const _replySeparator = '---------- Previous message ----------'; diff --git a/static/js/emailLibrary.js b/static/js/emailLibrary.js index 887459252..53134d0c1 100644 --- a/static/js/emailLibrary.js +++ b/static/js/emailLibrary.js @@ -1992,6 +1992,13 @@ function _renderSearchSuggestions(items) { ${esc(s.label)} `; } + if (s.kind === 'email') { + return `
+ + ${esc(s.subject)} + ${s.from_name ? `— ${esc(s.from_name)}` : ''} +
`; + } return `
${esc(s.name || s.email)} ${s.name ? `${esc(s.email)}` : ''} @@ -2019,6 +2026,21 @@ function _acceptSuggestion(s) { const input = document.getElementById('email-lib-search'); if (s.kind === 'filter') { _addSearchPill({ type: 'filter', value: s.value, label: s.label }); + } else if (s.kind === 'email') { + // Clear the draft + dropdown and open the matching card directly. + if (input) input.value = ''; + state._libSearchDraft = ''; + _hideSearchSuggestions(); + _applyPillFilter(); + const grid = document.getElementById('email-lib-grid'); + const card = grid?.querySelector(`.doclib-card[data-uid="${CSS.escape(String(s.uid))}"]`); + const em = (state._libEmails || []).find(x => String(x.uid) === String(s.uid)) + || (_libPreSearchEmails || []).find(x => String(x.uid) === String(s.uid)); + if (card && em) { + card.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); + _toggleCardPreview(card, em); + } + return; } else { _addSearchPill({ type: 'contact', name: s.name, email: s.email }); }