Skip to content

Commit e7be6d3

Browse files
authored
fix: Incorrect styling of IconFrame when using as prop (#556)
1 parent 8ca5043 commit e7be6d3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/IconFrame.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
type ComponentProps,
23
type ReactElement,
34
type ReactNode,
45
cloneElement,
@@ -143,7 +144,10 @@ const IconFrameSC = styled(Flex)<{
143144
: {}),
144145
}))
145146

146-
const IconFrame = forwardRef<HTMLDivElement, IconFrameProps>(
147+
const IconFrame = forwardRef<
148+
HTMLDivElement,
149+
IconFrameProps & ComponentProps<typeof IconFrameSC>
150+
>(
147151
(
148152
{
149153
icon,
@@ -154,6 +158,7 @@ const IconFrame = forwardRef<HTMLDivElement, IconFrameProps>(
154158
tooltip,
155159
tooltipProps,
156160
type = 'tertiary',
161+
as,
157162
...props
158163
},
159164
ref
@@ -162,6 +167,7 @@ const IconFrame = forwardRef<HTMLDivElement, IconFrameProps>(
162167
if (tooltip && typeof tooltip === 'boolean') {
163168
tooltip = textValue
164169
}
170+
const forwardedAs = as || (clickable ? ButtonBase : undefined)
165171

166172
let content = (
167173
<IconFrameSC
@@ -172,9 +178,8 @@ const IconFrame = forwardRef<HTMLDivElement, IconFrameProps>(
172178
ref={ref}
173179
flex={false}
174180
aria-label={textValue}
175-
forwardedAs={(props as any).as}
181+
{...(forwardedAs ? { forwardedAs } : {})}
176182
{...(clickable && {
177-
forwardedAs: (props as any).as || ButtonBase,
178183
tabIndex: 0,
179184
role: 'button',
180185
type: 'button',

0 commit comments

Comments
 (0)