Skip to content

Commit

Permalink
Made TagCloseButton a forwardRef (#6707)
Browse files Browse the repository at this point in the history
Co-authored-by: Jake Chapman <jake.chapman@mark43.com>
Co-authored-by: Segun Adebayo <joseshegs@gmail.com>
  • Loading branch information
3 people committed Sep 19, 2022
1 parent c570b24 commit 0ca7b09
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-walls-study.md
@@ -0,0 +1,5 @@
---
"@chakra-ui/tag": patch
---

Use `forwardRef` with `TagCloseButton`
53 changes: 28 additions & 25 deletions packages/components/tag/src/tag.tsx
Expand Up @@ -90,30 +90,33 @@ export interface TagCloseButtonProps
* TagCloseButton is used to close "remove" the tag
* @see Docs https://chakra-ui.com/tag
*/
export const TagCloseButton: React.FC<TagCloseButtonProps> = (props) => {
const { isDisabled, children, ...rest } = props

const styles = useTagStyles()

const btnStyles: SystemStyleObject = {
display: "flex",
alignItems: "center",
justifyContent: "center",
outline: "0",
...styles.closeButton,
}

return (
<chakra.button
aria-label="close"
{...rest}
type="button"
disabled={isDisabled}
__css={btnStyles}
>
{children || <TagCloseIcon />}
</chakra.button>
)
}
export const TagCloseButton = forwardRef<TagCloseButtonProps, "button">(
(props, ref) => {
const { isDisabled, children, ...rest } = props

const styles = useTagStyles()

const btnStyles: SystemStyleObject = {
display: "flex",
alignItems: "center",
justifyContent: "center",
outline: "0",
...styles.closeButton,
}

return (
<chakra.button
ref={ref}
aria-label="close"
{...rest}
type="button"
disabled={isDisabled}
__css={btnStyles}
>
{children || <TagCloseIcon />}
</chakra.button>
)
},
)

TagCloseButton.displayName = "TagCloseButton"

1 comment on commit 0ca7b09

@vercel
Copy link

@vercel vercel bot commented on 0ca7b09 Sep 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.