Skip to content

Commit c49f9ab

Browse files
Fix broken share button (#9253)
fix(webview-ui): make Share button popover work by forwarding ref in LucideIconButton - Convert LucideIconButton to forwardRef so Radix PopoverTrigger(asChild) receives a focusable element - Enables Share popover and shareCurrentTask flow - Verified with ShareButton/TaskActions Vitest suites
1 parent 2588309 commit c49f9ab

File tree

1 file changed

+33
-37
lines changed

1 file changed

+33
-37
lines changed
Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { forwardRef } from "react"
12
import { cn } from "@src/lib/utils"
23
import { Button, StandardTooltip } from "@src/components/ui"
34
import { Loader2, LucideIcon } from "lucide-react"
@@ -11,40 +12,35 @@ interface LucideIconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEle
1112
style?: React.CSSProperties
1213
}
1314

14-
export const LucideIconButton: React.FC<LucideIconButtonProps> = ({
15-
icon,
16-
title,
17-
className,
18-
disabled,
19-
tooltip = true,
20-
isLoading,
21-
onClick,
22-
style,
23-
...props
24-
}) => {
25-
const Icon = icon
26-
return (
27-
<StandardTooltip content={tooltip ? title : undefined}>
28-
<Button
29-
aria-label={title}
30-
className={cn(
31-
"relative inline-flex items-center justify-center",
32-
"bg-transparent border-none p-1.5",
33-
"rounded-full",
34-
"text-vscode-foreground opacity-85",
35-
"transition-all duration-150",
36-
"focus:outline-none focus-visible:ring-1 focus-visible:ring-vscode-focusBorder",
37-
"active:bg-[rgba(255,255,255,0.1)]",
38-
!disabled && "cursor-pointer hover:opacity-100 hover:bg-[rgba(255,255,255,0.03)]",
39-
disabled && "cursor-not-allowed opacity-40 hover:bg-transparent active:bg-transparent",
40-
className,
41-
)}
42-
disabled={disabled}
43-
onClick={!disabled ? onClick : undefined}
44-
style={{ fontSize: 16.5, ...style }}
45-
{...props}>
46-
{isLoading ? <Loader2 className="size-2.5 animate-spin" /> : <Icon className="size-2.5" />}
47-
</Button>
48-
</StandardTooltip>
49-
)
50-
}
15+
export const LucideIconButton = forwardRef<HTMLButtonElement, LucideIconButtonProps>(
16+
({ icon, title, className, disabled, tooltip = true, isLoading, onClick, style, ...props }, ref) => {
17+
const Icon = icon
18+
return (
19+
<StandardTooltip content={tooltip ? title : undefined}>
20+
<Button
21+
ref={ref}
22+
aria-label={title}
23+
className={cn(
24+
"relative inline-flex items-center justify-center",
25+
"bg-transparent border-none p-1.5",
26+
"rounded-full",
27+
"text-vscode-foreground opacity-85",
28+
"transition-all duration-150",
29+
"focus:outline-none focus-visible:ring-1 focus-visible:ring-vscode-focusBorder",
30+
"active:bg-[rgba(255,255,255,0.1)]",
31+
!disabled && "cursor-pointer hover:opacity-100 hover:bg-[rgba(255,255,255,0.03)]",
32+
disabled && "cursor-not-allowed opacity-40 hover:bg-transparent active:bg-transparent",
33+
className,
34+
)}
35+
disabled={disabled}
36+
onClick={!disabled ? onClick : undefined}
37+
style={{ fontSize: 16.5, ...style }}
38+
{...props}>
39+
{isLoading ? <Loader2 className="size-2.5 animate-spin" /> : <Icon className="size-2.5" />}
40+
</Button>
41+
</StandardTooltip>
42+
)
43+
},
44+
)
45+
46+
LucideIconButton.displayName = "LucideIconButton"

0 commit comments

Comments
 (0)