Skip to content

Commit 457297c

Browse files
authored
🤖 fix: forward props in HelpIndicator for Radix tooltip compatibility (#1095)
HelpIndicator wasn't spreading rest props, so Radix's `asChild` couldn't attach event handlers for tooltip triggering. _Generated with `mux`_
1 parent 903e7a6 commit 457297c

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

‎src/browser/components/ui/tooltip.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
4848

4949
const HelpIndicator = React.forwardRef<
5050
HTMLSpanElement,
51-
{ className?: string; children?: React.ReactNode }
52-
>(({ className, children }, ref) => (
51+
React.HTMLAttributes<HTMLSpanElement> & { className?: string; children?: React.ReactNode }
52+
>(({ className, children, ...props }, ref) => (
5353
<span
5454
ref={ref}
5555
className={cn("text-muted flex cursor-help items-center text-[10px] leading-none", className)}
56+
{...props}
5657
>
5758
{children}
5859
</span>

‎src/browser/stories/App.chat.stories.tsx‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,58 @@ export const BackgroundProcesses: AppStory = {
443443
},
444444
},
445445
};
446+
447+
/**
448+
* Mode selector with HelpIndicator tooltip - verifies props forwarding for Radix asChild.
449+
*
450+
* Regression test: HelpIndicator must spread rest props so TooltipTrigger's asChild
451+
* can attach event handlers for tooltip triggering.
452+
*
453+
* The fix ensures HelpIndicator forwards props (like onPointerEnter, onFocus) that
454+
* Radix TooltipTrigger needs when using asChild. Without the fix, the tooltip
455+
* would never appear on hover/focus.
456+
*/
457+
export const ModeHelpTooltip: AppStory = {
458+
render: () => (
459+
<AppWithMocks
460+
setup={() =>
461+
setupSimpleChatStory({
462+
messages: [],
463+
})
464+
}
465+
/>
466+
),
467+
play: async ({ canvasElement }) => {
468+
const canvas = within(canvasElement);
469+
470+
// Wait for app to fully load - the chat input with mode selector should be present
471+
await canvas.findAllByText("Exec", {}, { timeout: 10000 });
472+
473+
// Find the help indicator "?" - should be a span with cursor-help styling
474+
const helpIndicators = canvas.getAllByText("?");
475+
const helpIndicator = helpIndicators.find(
476+
(el) => el.tagName === "SPAN" && el.className.includes("cursor-help")
477+
);
478+
if (!helpIndicator) throw new Error("HelpIndicator not found");
479+
480+
// Hover to open the tooltip and leave it visible for the visual snapshot
481+
await userEvent.hover(helpIndicator);
482+
483+
// Wait for tooltip to fully appear (Radix has 200ms delay)
484+
await waitFor(
485+
() => {
486+
const tooltip = document.querySelector('[role="tooltip"]');
487+
if (!tooltip) throw new Error("Tooltip not visible");
488+
},
489+
{ timeout: 2000, interval: 50 }
490+
);
491+
},
492+
parameters: {
493+
docs: {
494+
description: {
495+
story:
496+
"Verifies the HelpIndicator tooltip works by focusing the ? icon. The tooltip should appear with Exec/Plan mode explanations.",
497+
},
498+
},
499+
},
500+
};

0 commit comments

Comments
 (0)