Skip to content

Commit

Permalink
Support duplicating
Browse files Browse the repository at this point in the history
  • Loading branch information
134130 committed Aug 9, 2023
1 parent 4b5570b commit 63be27f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions react-multi-email/ReactMultiEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface IReactMultiEmailProps {
disableOnBlurValidation?: boolean;
allowDisplayName?: boolean;
stripDisplayName?: boolean;
allowDuplicate?: boolean;
}

const initialEmailAddress = (emails?: string[]) => {
Expand All @@ -52,6 +53,7 @@ export function ReactMultiEmail(props: IReactMultiEmailProps) {
autoFocus,
allowDisplayName = false,
stripDisplayName = false,
allowDuplicate = false,
delimiter = `[${allowDisplayName ? '' : ' '},;]`,
initialInputValue = '',
inputClassName,
Expand Down Expand Up @@ -84,9 +86,11 @@ export function ReactMultiEmail(props: IReactMultiEmailProps) {
const isEmail = validateEmail || isEmailFn;

const addEmails = (email: string) => {
for (let i = 0, l = emails.length; i < l; i++) {
if (emails[i] === email) {
return false;
if (!allowDuplicate) {
for (let i = 0, l = emails.length; i < l; i++) {
if (emails[i] === email) {
return false;
}
}
}
validEmails.push(email);
Expand Down

0 comments on commit 63be27f

Please sign in to comment.