From 26033aa76aadc7ac85397626737dca07303eeef2 Mon Sep 17 00:00:00 2001 From: roo hutton Date: Fri, 10 Oct 2025 10:18:24 +0100 Subject: [PATCH] Merge pull request #28775 from overleaf/rh-dedupe-share-modal Deduplicate emails when pasted in share modal GitOrigin-RevId: 6c66b51fdbcc5ea3a24ea54523b5a47036fb3fb1 --- .../components/select-collaborators.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/features/share-project-modal/components/select-collaborators.tsx b/services/web/frontend/js/features/share-project-modal/components/select-collaborators.tsx index 19607bd2d8..af50df978d 100644 --- a/services/web/frontend/js/features/share-project-modal/components/select-collaborators.tsx +++ b/services/web/frontend/js/features/share-project-modal/components/select-collaborators.tsx @@ -237,12 +237,18 @@ export default function SelectCollaborators({ const emails = data .split(/[\r\n,; ]+/) .filter(item => item.includes('@')) + .map(email => email.replace(matchAllSpaces, '')) if (emails.length) { // pasted comma-separated email addresses event.preventDefault() - for (const email of emails) { + // dedupe emails in pasted content and previously-entered items + const uniqueEmails = [...new Set(emails)].filter( + email => !selectedEmails.includes(email) + ) + + for (const email of uniqueEmails) { addNewItem(email) } }