mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-04 16:14:07 +00:00
fix: drop ticked messages when a category tab or filter chip changes the list
This commit is contained in:
@@ -71,6 +71,15 @@ describe('plugin list filters in the message list', () => {
|
||||
expect(fetchEmails).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('drops ticked messages when a chip narrows the list', async () => {
|
||||
useEmailStore.setState({ selectedEmailKeys: new Set(['a', 'b']) });
|
||||
render(<EmailList emails={[]} />);
|
||||
const chip = await screen.findByRole('button', { name: 'Open' });
|
||||
expect(useEmailStore.getState().selectedEmailKeys.size).toBe(2);
|
||||
act(() => { fireEvent.click(chip); });
|
||||
expect(useEmailStore.getState().selectedEmailKeys.size).toBe(0);
|
||||
});
|
||||
|
||||
it('does not call the folder empty while a filter hides its mail', async () => {
|
||||
render(<EmailList emails={[]} />);
|
||||
expect(await screen.findByText('no_emails_description')).toBeInTheDocument();
|
||||
|
||||
@@ -51,6 +51,15 @@ describe('MessageListTabs', () => {
|
||||
expect(screen.getByRole('tabpanel', { name: 'Primary' })).toHaveTextContent('list');
|
||||
});
|
||||
|
||||
it('drops ticked messages on a switch of tab, which lists other mail', () => {
|
||||
useEmailStore.setState({ selectedEmailKeys: new Set(['a', 'b']) } as never);
|
||||
render(<Harness />);
|
||||
fireEvent.click(screen.getByRole('tab', { name: 'Primary' }));
|
||||
expect(useEmailStore.getState().selectedEmailKeys.size).toBe(2);
|
||||
fireEvent.click(screen.getByRole('tab', { name: 'Social' }));
|
||||
expect(useEmailStore.getState().selectedEmailKeys.size).toBe(0);
|
||||
});
|
||||
|
||||
it('keeps one tab stop and moves with the arrow keys', () => {
|
||||
render(<Harness />);
|
||||
const [primary, promotions, social] = screen.getAllByRole('tab');
|
||||
|
||||
@@ -1177,7 +1177,7 @@ export function EmailList({
|
||||
<PluginListFilters
|
||||
mailboxRole={effectiveMailboxRole ?? null}
|
||||
accountKind={folderAccountKind}
|
||||
onChange={() => { if (client) void useEmailStore.getState().fetchEmails(client); }}
|
||||
onChange={() => { clearSelection(); if (client) void useEmailStore.getState().fetchEmails(client); }}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
@@ -99,6 +99,8 @@ export function MessageListTabs({ panelId }: { panelId: string }) {
|
||||
const handleSelect = (tabId: string) => {
|
||||
if (tabId === activeTabId) return;
|
||||
useMessageListTabsStore.getState().setActiveTab(tabId, selectedMailbox);
|
||||
// The other tab lists other mail; ticks here would act on rows out of sight.
|
||||
useEmailStore.getState().clearSelection();
|
||||
if (client) void useEmailStore.getState().fetchEmails(client);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user