fix(site): convert div role="button" to native button in ai-elements tools (#22631)

This commit is contained in:
Danielle Maywood
2026-03-05 09:58:37 +00:00
committed by GitHub
parent 9c91f472b9
commit 024d07350a
4 changed files with 18 additions and 41 deletions
@@ -92,17 +92,11 @@ export const ExecuteTool: React.FC<{
{/* Expand / collapse toggle at the bottom */}
{overflows && (
<div
role="button"
tabIndex={0}
<button
type="button"
aria-expanded={expanded}
onClick={() => setExpanded((v) => !v)}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
setExpanded((v) => !v);
}
}}
className="flex w-full cursor-pointer items-center justify-center py-0.5 text-content-secondary transition-colors hover:bg-surface-secondary hover:text-content-primary"
className="border-0 bg-transparent m-0 font-[inherit] text-[inherit] flex w-full cursor-pointer items-center justify-center py-0.5 text-content-secondary transition-colors hover:bg-surface-secondary hover:text-content-primary"
aria-label={expanded ? "Collapse output" : "Expand output"}
>
<ChevronDownIcon
@@ -111,7 +105,7 @@ export const ExecuteTool: React.FC<{
expanded && "rotate-180",
)}
/>
</div>
</button>
)}
</>
)}
@@ -73,17 +73,11 @@ export const ProcessOutputTool: React.FC<{
{/* Expand / collapse toggle at the bottom */}
{overflows && (
<div
role="button"
tabIndex={0}
<button
type="button"
aria-expanded={expanded}
onClick={() => setExpanded((v) => !v)}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
setExpanded((v) => !v);
}
}}
className="flex w-full cursor-pointer items-center justify-center py-0.5 text-content-secondary transition-colors hover:bg-surface-secondary hover:text-content-primary"
className="border-0 bg-transparent m-0 font-[inherit] text-[inherit] flex w-full cursor-pointer items-center justify-center py-0.5 text-content-secondary transition-colors hover:bg-surface-secondary hover:text-content-primary"
aria-label={expanded ? "Collapse output" : "Expand output"}
>
<ChevronDownIcon
@@ -92,7 +86,7 @@ export const ProcessOutputTool: React.FC<{
expanded && "rotate-180",
)}
/>
</div>
</button>
)}
</>
) : (
@@ -93,18 +93,13 @@ export const SubagentTool: React.FC<{
return (
<div className="w-full">
<div
role="button"
tabIndex={0}
<button
type="button"
aria-expanded={expanded}
onClick={() => hasExpandableContent && setExpanded((v) => !v)}
onKeyDown={(e) => {
if ((e.key === "Enter" || e.key === " ") && hasExpandableContent) {
setExpanded((v) => !v);
}
}}
className={cn(
"flex items-center gap-2",
"border-0 bg-transparent p-0 m-0 font-[inherit] text-[inherit] text-left",
"flex w-full items-center gap-2",
hasExpandableContent && "cursor-pointer",
)}
>
@@ -142,7 +137,7 @@ export const SubagentTool: React.FC<{
)}
/>
)}
</div>
</button>
{expanded && hasPrompt && (
<ScrollArea
@@ -24,19 +24,13 @@ export const ToolCollapsible: FC<ToolCollapsibleProps> = ({
return (
<div className={className}>
{hasContent ? (
<div
role="button"
tabIndex={0}
<button
type="button"
aria-expanded={expanded}
onClick={() => setExpanded(!expanded)}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
setExpanded(!expanded);
}
}}
className={cn(
"flex items-center gap-2 cursor-pointer",
"border-0 bg-transparent p-0 m-0 font-[inherit] text-[inherit] text-left",
"flex w-full items-center gap-2 cursor-pointer",
headerClassName,
)}
>
@@ -47,7 +41,7 @@ export const ToolCollapsible: FC<ToolCollapsibleProps> = ({
expanded ? "rotate-0" : "-rotate-90",
)}
/>
</div>
</button>
) : (
<div className={cn("flex items-center gap-2", headerClassName)}>
{header}