Skip to content

The agent that grows with you

fix(desktop): keep tooltip wrappers from blocking fan controls

brooklyn!7b6e0d3848ce
diff --git a/apps/desktop/src/components/ui/fan-menu-tooltip.test.tsx b/apps/desktop/src/components/ui/fan-menu-tooltip.test.tsx
new file mode 100644
index 00000000000..4d930fbd255
--- /dev/null
+++ b/apps/desktop/src/components/ui/fan-menu-tooltip.test.tsx
@@ -0,0 +1,53 @@
+import { cleanup, fireEvent, render, screen } from '@testing-library/react'
+import type { ReactNode } from 'react'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+
+import { FanMenu } from './fan-menu'
+
+vi.mock('./tooltip', () => ({
+ Tip: ({ children, side }: { children: ReactNode; side: string }) => (
+ <span data-testid="tip" data-tip-side={side}>{children}</span>
+ )
+}))
+
+afterEach(cleanup)
+
+describe('FanMenu hub tooltip', () => {
+ it.each([
+ ['vertical', 'left'],
+ ['horizontal', 'top'],
+ ['arc', 'bottom']
+ ] as const)('keeps the %s hub tooltip outside its open fan', (direction, side) => {
+ render(
+ <FanMenu
+ direction={direction}
+ hub={{ id: 'hub', icon: 'H', label: 'Hub', onSelect: vi.fn() }}
+ items={[{ id: 'option', icon: 'O', label: 'Option', onSelect: vi.fn() }]}
+ label="Fan"
+ />
+ )
+
+ const hub = screen.getByRole('button', { name: 'Hub' })
+
+ expect(hub.closest('[data-tip-side]')?.getAttribute('data-tip-side')).toBe('top')
+ fireEvent.pointerEnter(hub)
+ expect(hub.closest('[data-tip-side]')?.getAttribute('data-tip-side')).toBe(side)
+ })
+
+ it('keeps an explicit side override when the fan opens', () => {
+ render(
+ <FanMenu
+ direction="arc"
+ hub={{ id: 'hub', icon: 'H', label: 'Hub', onSelect: vi.fn() }}
+ items={[]}
+ label="Fan"
+ tipAnchor="right"
+ />
+ )
+
+ const hub = screen.getByRole('button', { name: 'Hub' })
+
+ fireEvent.pointerEnter(hub)
+ expect(hub.closest('[data-tip-side]')?.getAttribute('data-tip-side')).toBe('right')
+ })
+})
diff --git a/apps/desktop/src/components/ui/fan-menu.tsx b/apps/desktop/src/components/ui/fan-menu.tsx
index ac2ea23b895..0d1c722e3ed 100644
--- a/apps/desktop/src/components/ui/fan-menu.tsx
+++ b/apps/desktop/src/components/ui/fan-menu.tsx
@@ -116,6 +116,8 @@ export function fanOffsets(direction: FanDirection, count: number, step: number)
const sameRect = (a: DOMRect | null, b: DOMRect) =>
a !== null && a.left === b.left && a.top === b.top && a.width === b.width && a.height === b.height
+const OPEN_HUB_TIP_SIDE = { vertical: 'left', horizontal: 'top', arc: 'bottom' } as const
+
function fanTipSide(direction: FanDirection, offset: Point): NonNullable<FanMenuProps['tipAnchor']> {
if (direction === 'vertical') {
return 'left'
@@ -250,7 +252,7 @@ export function FanMenu({ direction = 'vertical', gap = 4, hint = true, hub, ite
onPointerLeave={hideSoon}
ref={anchorRef}
>
- <Tip label={hub.label} side={tipAnchor ?? (open && direction === 'vertical' ? 'left' : 'top')}>
+ <Tip label={hub.label} side={tipAnchor ?? (open ? OPEN_HUB_TIP_SIDE[direction] : 'top')}>
<Button
aria-expanded={open}
aria-haspopup="true"
diff --git a/apps/desktop/src/components/ui/tooltip.css b/apps/desktop/src/components/ui/tooltip.css
index 0e9adf7a9cf..5cc5f7ce6c4 100644
--- a/apps/desktop/src/components/ui/tooltip.css
+++ b/apps/desktop/src/components/ui/tooltip.css
@@ -7,6 +7,12 @@
transform-origin: var(--radix-tooltip-content-transform-origin);
}
+/* Radix's positioning wrapper otherwise intercepts adjacent controls even
+ when the visible content has pointer-events: none. Leave other poppers alone. */
+[data-radix-popper-content-wrapper]:has(> .tooltip-bubble) {
+ pointer-events: none;
+}
+
.tooltip-bubble[data-state='closed'] {
animation: tooltip-exit 100ms ease-in both;
}