diff --git a/hooks/__tests__/use-calendar-event-search.test.tsx b/hooks/__tests__/use-calendar-event-search.test.tsx index 931d69726..a91bd1d3d 100644 --- a/hooks/__tests__/use-calendar-event-search.test.tsx +++ b/hooks/__tests__/use-calendar-event-search.test.tsx @@ -60,6 +60,17 @@ describe('useCalendarEventSearch (CAL-16)', () => { expect(result.current?.past.map((e) => e.id)).toEqual(['old', 'older']); }); + it('shows a series under its own title when its next occurrence was renamed', () => { + const { client } = clientWith(() => new Promise(() => {})); + const series = [ + makeEvent('sync-1', 'Sync edited', '2026-10-29T10:00:00', { uid: 'sync', recurrenceId: '2026-10-29T10:00:00' }), + makeEvent('sync-2', 'Sync', '2026-11-05T10:00:00', { uid: 'sync', recurrenceId: '2026-11-05T10:00:00' }), + makeEvent('sync-3', 'Sync', '2026-11-12T10:00:00', { uid: 'sync', recurrenceId: '2026-11-12T10:00:00' }), + ]; + const { result } = renderHook(() => useCalendarEventSearch('sync', client, series)); + expect(result.current?.upcoming.map((e) => e.id)).toEqual(['sync-1', 'sync-2']); + }); + it('keeps the loaded matches when the server can not search', async () => { const { client } = clientWith(async () => { throw new Error('unsupportedFilter'); }); const { result } = renderHook(() => useCalendarEventSearch('review', client, loaded)); diff --git a/hooks/use-calendar-event-search.ts b/hooks/use-calendar-event-search.ts index 9d8122c28..a1f48e830 100644 --- a/hooks/use-calendar-event-search.ts +++ b/hooks/use-calendar-event-search.ts @@ -22,8 +22,11 @@ export interface CalendarSearchResults { } // One row per event: a series found as loaded occurrences and as the -// server's base event shows once. -const seriesKey = (event: CalendarEvent) => `${event.accountId ?? ""} ${event.uid || event.originalId || event.id}`; +// server's base event shows once. An occurrence renamed on its own gets a +// row of its own, so the series still shows under its own title: the next +// occurrence being the renamed one hid the series. +const seriesKey = (event: CalendarEvent) => + `${event.accountId ?? ""} ${event.uid || event.originalId || event.id} ${event.title ?? ""}`; /** * Searches the user's events by title, place, description and participants