mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-06 00:15:32 +00:00
fix: add the open contact to the selection on Ctrl+click and Shift+click in Contacts
This commit is contained in:
@@ -131,6 +131,21 @@ describe('ContactsApp', () => {
|
||||
expect(useContactStore.getState().selectedContactId).toBe('c-bob');
|
||||
});
|
||||
|
||||
it('adds the open contact to the selection on Ctrl+click, as Files does', () => {
|
||||
renderContacts();
|
||||
fireEvent.click(screen.getByText('Alice Smith'));
|
||||
fireEvent.click(screen.getByText('Bob Jones'), { ctrlKey: true });
|
||||
expect([...useContactStore.getState().selectedContactIds].sort()).toEqual(['c-alice', 'c-bob']);
|
||||
});
|
||||
|
||||
it('selects from the open contact on Shift+click', () => {
|
||||
const carol: ContactCard = { ...bob, id: 'c-carol', name: { full: 'Carol King' }, emails: { e0: { address: 'carol@example.com' } } };
|
||||
renderContacts([alice, bob, carol]);
|
||||
fireEvent.click(screen.getByText('Bob Jones'));
|
||||
fireEvent.click(screen.getByText('Carol King'), { shiftKey: true });
|
||||
expect([...useContactStore.getState().selectedContactIds].sort()).toEqual(['c-bob', 'c-carol']);
|
||||
});
|
||||
|
||||
it('leaves an untouched contact form without asking', () => {
|
||||
renderContacts();
|
||||
fireEvent.click(screen.getByText('Alice Smith'));
|
||||
|
||||
@@ -720,11 +720,17 @@ export function ContactList({
|
||||
density={density}
|
||||
selectedContactIds={selectedContactIds}
|
||||
onClick={(e) => {
|
||||
// The open contact counts as selected, as a clicked file does
|
||||
// in Files: Ctrl/⌘+click and Shift+click build on it.
|
||||
const startFromOpen = !hasSelection && !!selectedContactId
|
||||
&& selectedContactId !== contact.id && sortedIds.includes(selectedContactId);
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
e.preventDefault();
|
||||
if (startFromOpen) onToggleSelection(selectedContactId);
|
||||
onToggleSelection(contact.id);
|
||||
} else if (e.shiftKey) {
|
||||
e.preventDefault();
|
||||
if (startFromOpen) onToggleSelection(selectedContactId);
|
||||
onSelectRangeContacts(contact.id, sortedIds);
|
||||
} else {
|
||||
if (hasSelection) onClearSelection();
|
||||
|
||||
Reference in New Issue
Block a user