Skip to content

Commit

Permalink
fix(Tag): render button when nonfilter tag is interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
emyarod committed Mar 2, 2021
1 parent 62deccf commit 248029e
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions packages/react/src/components/Tag/Tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,39 @@ const Tag = ({
}
};

return filter ? (
<div
className={tagClasses}
aria-label={
title !== undefined
? `${title} ${children}`
: `Clear filter ${children}`
}
id={tagId}
{...other}>
<span
className={`${prefix}--tag__label`}
title={typeof children === 'string' ? children : null}>
{children !== null && children !== undefined ? children : TYPES[type]}
</span>
<button
type="button"
className={`${prefix}--tag__close-icon`}
onClick={handleClose}
disabled={disabled}
aria-labelledby={tagId}
title={title}>
<Close16 />
</button>
</div>
) : (
<div className={tagClasses} id={tagId} {...other}>
if (filter) {
return (
<div
className={tagClasses}
aria-label={
title !== undefined
? `${title} ${children}`
: `Clear filter ${children}`
}
id={tagId}
{...other}>
<span
className={`${prefix}--tag__label`}
title={typeof children === 'string' ? children : null}>
{children !== null && children !== undefined ? children : TYPES[type]}
</span>
<button
type="button"
className={`${prefix}--tag__close-icon`}
onClick={handleClose}
disabled={disabled}
aria-labelledby={tagId}
title={title}>
<Close16 />
</button>
</div>
);
}

const ComponentTag = other.onClick ? 'button' : 'div';

return (
<ComponentTag className={tagClasses} id={tagId} {...other}>
{CustomIconElement ? (
<div className={`${prefix}--tag__custom-icon`}>
<CustomIconElement />
Expand All @@ -93,7 +99,7 @@ const Tag = ({
<span title={typeof children === 'string' ? children : null}>
{children !== null && children !== undefined ? children : TYPES[type]}
</span>
</div>
</ComponentTag>
);
};

Expand Down

0 comments on commit 248029e

Please sign in to comment.