Skip to content

Commit 647498f

Browse files
authored
Handle close on Tag cross click (#633)
1 parent 8351a7c commit 647498f

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nordcloud/gnui",
33
"description": "Nordcloud Design System - a collection of reusable React components used in Nordcloud's SaaS products",
4-
"version": "8.13.3",
4+
"version": "8.13.4",
55
"license": "MIT",
66
"repository": {
77
"type": "git",

src/components/tag/Tag.stories.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import { Breadcrumbs } from "../breadcrumbs";
6666
text="Help"
6767
showClose
6868
onClick={() => alert("clicked")}
69+
onCloseClick={() => alert("clicked close")}
6970
/>
7071
<Tag
7172
color="purple"

src/components/tag/Tag.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type TagProps = {
1212
text?: string;
1313
icon?: SVGIconProps["name"];
1414
onClick?: () => void;
15+
onCloseClick?: () => void;
1516
showClose?: boolean;
1617
isTransparent?: boolean;
1718
};
@@ -125,16 +126,17 @@ export function Tag({
125126
onClick,
126127
showClose,
127128
isTransparent,
129+
onCloseClick,
128130
...props
129131
}: TagProps) {
130132
return (
131133
<StyledTag
132134
color={color}
133135
colorText={colorText}
134136
icon={icon}
135-
onClick={onClick}
136137
showClose={showClose}
137138
isTransparent={isTransparent}
139+
onClick={onCloseClick ? undefined : onClick}
138140
{...props}
139141
>
140142
{icon && (
@@ -145,7 +147,7 @@ export function Tag({
145147
{text && <div className="tag-text">{text}</div>}
146148
{showClose && (
147149
<div className="tag-close-button">
148-
<SVGIcon name="close" size="sm" />
150+
<SVGIcon name="close" size="sm" onClick={onCloseClick} />
149151
</div>
150152
)}
151153
</StyledTag>

0 commit comments

Comments
 (0)