Skip to content

Commit 4c3c746

Browse files
refactor(skillTag): optimize click handler with spread operator (#1027)
Co-authored-by: ypatadia-eightfold <ypatadia@eightfold.ai>
1 parent 7abf1b4 commit 4c3c746

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/components/Skill/SkillTag.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,16 @@ export const SkillTag: FC<SkillTagProps> = React.forwardRef(
170170
>
171171
<div
172172
className={styles.background}
173-
onClick={(e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
174-
if (
175-
readonly ||
176-
disabled ||
177-
!clickable ||
178-
size === SkillSize.XSmall ||
179-
e.target !== e.currentTarget
180-
) {
181-
return;
182-
}
183-
onClick?.(e);
184-
}}
173+
{...(!readonly && !disabled && clickable && size !== SkillSize.XSmall
174+
? {
175+
onClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
176+
if (e.target !== e.currentTarget) {
177+
return;
178+
}
179+
onClick?.(e);
180+
},
181+
}
182+
: {})}
185183
style={{ background }}
186184
></div>
187185
<div className={styles.content}>{children}</div>

0 commit comments

Comments
 (0)