Skip to content

Commit 24b9b19

Browse files
committed
refactor(tag): ♻️ fix overlapping cases of suffix and closable, suffix takes precedence
1 parent 14b63c1 commit 24b9b19

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/components/tag/Tag.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const RNTag: React.FC<Partial<TagProps>> = forwardRef<
8181
themeColor = "base",
8282
closable = false,
8383
prefix,
84-
suffix = closable ? <Icon icon={<Close />} /> : null,
84+
suffix: suffixFromProps,
8585
style,
8686
textStyle,
8787
accesibilityLabel,
@@ -110,6 +110,11 @@ const RNTag: React.FC<Partial<TagProps>> = forwardRef<
110110
</Box>
111111
));
112112

113+
const suffix = suffixFromProps ? (
114+
suffixFromProps
115+
) : closable ? (
116+
<Icon icon={<Close />} />
117+
) : null;
113118
/* Suffix Slot */
114119
const _suffix =
115120
suffix &&
@@ -214,13 +219,11 @@ const RNTag: React.FC<Partial<TagProps>> = forwardRef<
214219
>
215220
{_prefix}
216221
{children}
217-
{closable && _suffix}
222+
{_suffix}
218223
</Touchable>
219224
);
220225
});
221226

222-
RNTag.displayName = "RNTag";
223-
224227
export const Tag = createComponent<Partial<TagProps>>(RNTag, {
225228
shouldMemo: true,
226229
});

0 commit comments

Comments
 (0)