Skip to content

Commit cc8b8b2

Browse files
moinakmalkhanMOIN
andauthored
Prevent default behaviour when validation failed (#31)
Co-authored-by: MOIN <moin@Apples-MacBook-Pro.local>
1 parent 574e64d commit cc8b8b2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export const TagsInput = ({
7272
}
7373

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

7778
if (tags.includes(text)) {
@@ -80,7 +81,6 @@ export const TagsInput = ({
8081
}
8182
setTags([...tags, text]);
8283
e.target.value = "";
83-
e.preventDefault();
8484
}
8585
};
8686

0 commit comments

Comments
 (0)