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 9854348 commit 1f7de7c
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 @@ -25,6 +25,7 @@ export interface IReactMultiEmailProps {
inputClassName?: string;
placeholder?: string | React.ReactNode;
autoFocus?: boolean;
duplicate?: boolean;
spinner?: () => React.ReactNode;
delimiter?: string;
initialInputValue?: string;
Expand All @@ -40,6 +41,7 @@ export function ReactMultiEmail(props: IReactMultiEmailProps) {
noClass,
placeholder,
autoFocus,
duplicate,
enable,
onDisabled,
validateEmail,
Expand Down Expand Up @@ -70,9 +72,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 (!duplicate) {
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 1f7de7c

Please sign in to comment.