fix: avoid tooltip dropdown popper nesting

This commit is contained in:
lucaronin
2026-04-27 20:58:31 +02:00
parent ee90b05159
commit 1301653b81
2 changed files with 43 additions and 19 deletions

View File

@@ -23,6 +23,30 @@ describe('AiAgentsBadge', () => {
vi.clearAllMocks()
})
it('keeps the dropdown trigger off the Radix tooltip popper path', () => {
render(
<AiAgentsBadge
statuses={installedStatuses}
defaultAgent="claude_code"
onSetDefaultAgent={vi.fn()}
/>,
)
const trigger = screen.getByTestId('status-ai-agents')
expect(trigger).toHaveAttribute('data-tooltip-mode', 'native-title')
expect(trigger.getAttribute('title')).toContain('Claude Code')
act(() => {
trigger.focus()
})
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument()
act(() => {
fireEvent.keyDown(trigger, { key: 'ArrowDown' })
})
expect(screen.getByTestId('status-ai-agents-menu')).toBeInTheDocument()
})
it('shows the vault guidance summary and restore action', async () => {
const onRestoreGuidance = vi.fn()

View File

@@ -1,6 +1,5 @@
import { AlertTriangle, ChevronsUpDown } from 'lucide-react'
import { Sparkle } from '@phosphor-icons/react'
import { ActionTooltip } from '@/components/ui/action-tooltip'
import { Button } from '@/components/ui/button'
import {
AI_AGENT_DEFINITIONS,
@@ -240,6 +239,7 @@ export function AiAgentsBadge({
const selectedAgentReady = isAiAgentInstalled(statuses, defaultAgent)
const showWarning = hasAiAgentWarning(statuses, defaultAgent, guidanceStatus)
const showSwitcherCue = !showWarning && canShowSwitcherCue(statuses, defaultAgent)
const tooltip = badgeTooltip(locale, statuses, defaultAgent, guidanceStatus)
if (isAiAgentsStatusChecking(statuses)) return null
@@ -247,24 +247,24 @@ export function AiAgentsBadge({
<>
<CompactSeparator compact={compact} />
<DropdownMenu>
<ActionTooltip copy={{ label: badgeTooltip(locale, statuses, defaultAgent, guidanceStatus) }} side="top">
<DropdownMenuTrigger asChild={true}>
<Button
type="button"
variant="ghost"
size="xs"
className={triggerButtonClassName(compact)}
aria-label={translate(locale, 'status.ai.openOptions')}
data-testid="status-ai-agents"
>
<span style={{ ...ICON_STYLE, color: showWarning ? 'var(--accent-orange)' : 'var(--muted-foreground)' }}>
<Sparkle size={13} weight="fill" />
<TriggerLabel compact={compact} defaultAgent={defaultAgent} />
<TriggerStateIcon showWarning={showWarning} showSwitcherCue={showSwitcherCue} />
</span>
</Button>
</DropdownMenuTrigger>
</ActionTooltip>
<DropdownMenuTrigger asChild={true}>
<Button
type="button"
variant="ghost"
size="xs"
className={triggerButtonClassName(compact)}
aria-label={translate(locale, 'status.ai.openOptions')}
title={tooltip}
data-tooltip-mode="native-title"
data-testid="status-ai-agents"
>
<span style={{ ...ICON_STYLE, color: showWarning ? 'var(--accent-orange)' : 'var(--muted-foreground)' }}>
<Sparkle size={13} weight="fill" />
<TriggerLabel compact={compact} defaultAgent={defaultAgent} />
<TriggerStateIcon showWarning={showWarning} showSwitcherCue={showSwitcherCue} />
</span>
</Button>
</DropdownMenuTrigger>
<AgentMenuContent
statuses={statuses}
guidanceStatus={guidanceStatus}