Skip to content

Commit 57ce9fb

Browse files
🐛 prevent event bubbling on tags
1 parent 7d4f350 commit 57ce9fb

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-tag-input-component",
33
"description": "lightweight component for tag(s) input",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"license": "MIT",
66
"author": "Harsh Zalavadiya",
77
"module": "dist/react-tag-input-component.esm.js",

src/tag.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,19 @@ const tagStyles = css({
3030
});
3131

3232
export default function Tag({ text, remove }: TagProps) {
33-
const handleOnRemove = () => remove(text);
33+
const handleOnRemove = e => {
34+
e.stopPropagation();
35+
remove(text);
36+
};
3437

3538
return (
3639
<span className={cc("rti--tag", tagStyles)}>
3740
<span>{text}</span>
38-
<button onClick={handleOnRemove} aria-label={`remove ${text}`}>
41+
<button
42+
type="button"
43+
onClick={handleOnRemove}
44+
aria-label={`remove ${text}`}
45+
>
3946
&#10005;
4047
</button>
4148
</span>

0 commit comments

Comments
 (0)