diff --git a/frontend/src/components/GuestList.jsx b/frontend/src/components/GuestList.jsx index 5656b26..ef3fc64 100644 --- a/frontend/src/components/GuestList.jsx +++ b/frontend/src/components/GuestList.jsx @@ -193,15 +193,25 @@ function GuestList({ eventId, onBack, onShowMembers }) { // Apply search and filter logic const filteredGuests = guests.filter(guest => { - // Text search - search in name, email, phone + // Text search — normalize whitespace first, then match token-by-token so that: + // • trailing/leading spaces don't break results ("דור " == "דור") + // • multiple spaces collapse to one ("דור נחמני" == "דור נחמני") + // • full-name search works ("דור נחמני" matches first="דור" last="נחמני") if (searchFilters.query) { - const query = searchFilters.query.toLowerCase() - const matchesQuery = - guest.first_name?.toLowerCase().includes(query) || - guest.last_name?.toLowerCase().includes(query) || - guest.email?.toLowerCase().includes(query) || - guest.phone_number?.toLowerCase().includes(query) - if (!matchesQuery) return false + const normalized = searchFilters.query.trim().replace(/\s+/g, ' ') + if (normalized === '') { + // After normalization the query is blank → treat as "no filter" + } else { + const tokens = normalized.toLowerCase().split(' ').filter(Boolean) + const haystack = [ + guest.first_name || '', + guest.last_name || '', + guest.phone_number|| '', + guest.email || '', + ].join(' ').toLowerCase() + const matchesQuery = tokens.every(token => haystack.includes(token)) + if (!matchesQuery) return false + } } // RSVP Status filter