Skip to content

Commit

Permalink
Prevent default behaviour when validation failed (#31)
Browse files Browse the repository at this point in the history
Co-authored-by: MOIN <[email protected]>
  • Loading branch information
moinakmalkhan and MOIN authored Oct 10, 2022
1 parent 574e64d commit cc8b8b2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const TagsInput = ({
}

if (text && (separators || defaultSeparators).includes(e.key)) {
e.preventDefault();
if (beforeAddValidate && !beforeAddValidate(text, tags)) return;

if (tags.includes(text)) {
Expand All @@ -80,7 +81,6 @@ export const TagsInput = ({
}
setTags([...tags, text]);
e.target.value = "";
e.preventDefault();
}
};

Expand Down

0 comments on commit cc8b8b2

Please sign in to comment.