');
});
+ // compose-17: the button was there only with a server directory, so
+ // contacts alone were never offered.
+ it('offers the recipient picker for the contacts when the server has no directory', async () => {
+ const contactState = (useContactStore as unknown as { getState: () => { contacts: unknown[] } }).getState();
+ contactState.contacts = [{ id: 'c1', name: { full: 'Zoe Fischer' }, emails: { e: { address: 'zoe@example.com' } } }];
+ try {
+ await renderComposer();
+ const button = screen.getByTestId('composer-directory-picker');
+ expect(button).toHaveAccessibleName('picker_button');
+ fireEvent.click(button);
+ expect(screen.getByRole('dialog', { name: 'directory' })).toBeInTheDocument();
+ } finally {
+ contactState.contacts = [];
+ }
+ });
+
// The directory picker is drawn inside the composer itself, not portaled.
it('lets Escape in the directory picker leave the composer alone', async () => {
// Every other capability answers nothing.
diff --git a/components/email/email-composer.tsx b/components/email/email-composer.tsx
index 22ea0db2b..5f4a9ab85 100644
--- a/components/email/email-composer.tsx
+++ b/components/email/email-composer.tsx
@@ -1775,6 +1775,9 @@ export function EmailComposer({
// Whether a Sent mailbox is known so the on-demand server search is worth
// offering (falls back to hiding the "search the server" row otherwise).
const canSearchServer = useContactStore((s) => s.sentMailboxId != null);
+ // The recipient picker: the user's contacts, and the server's directory.
+ const hasContacts = useContactStore((s) => (s.contacts?.length ?? 0) > 0);
+ const tSend = useTranslations('compose_send');
const addToTrustedSendersBook = useContactStore((s) => s.addToTrustedSendersBook);
const addTrustedSender = useSettingsStore((s) => s.addTrustedSender);
const trustedSendersAddressBook = useSettingsStore((s) => s.trustedSendersAddressBook);
@@ -5091,15 +5094,15 @@ export function EmailComposer({
onMoveChip={handleMoveChip}
/>
- {activeClient?.supportsPrincipals?.() && (
+ {(hasContacts || activeClient?.supportsPrincipals?.()) && (