diff --git a/apps/desktop/src/components/ui/tooltip.lazy.test.tsx b/apps/desktop/src/components/ui/tooltip.lazy.test.tsx deleted file mode 100644 index 4a66eda5cd5d..000000000000 --- a/apps/desktop/src/components/ui/tooltip.lazy.test.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { fireEvent, render, screen, waitFor } from '@testing-library/react' -import { describe, expect, it } from 'vitest' - -import { Tip } from './tooltip' - -// `Tip` mounts Radix lazily (on first hover/focus) because ~107 eager -// providers dominated unrelated interactions — dragging the sidebar splitter -// measured 105k TooltipProvider renders across a 60-frame gesture. The saving -// is only worth anything if the tip still actually appears, so this asserts -// the behavior the optimization has to preserve, not its implementation. - -describe('Tip lazy mount', () => { - it('shows the tooltip on hover even though Radix mounts only once armed', async () => { - render( - - - - ) - - const trigger = screen.getByRole('button', { name: 'target' }) - - expect(screen.queryByText('Reveal in sidebar')).toBeNull() - - // Arms the lazy wrapper, then drives Radix's own trigger handlers for the - // same hover — the pointer is still inside, so the tip must open. - fireEvent.pointerEnter(trigger) - fireEvent.pointerMove(trigger) - - await waitFor(() => { - expect(screen.getAllByText('Reveal in sidebar').length).toBeGreaterThan(0) - }) - }) - - it('renders the child untouched when there is no label', () => { - const { container } = render( - - - - ) - - expect(screen.getByRole('button', { name: 'bare' })).toBeTruthy() - expect(container.querySelector('[data-slot="tooltip-idle"]')).toBeNull() - }) - - it('does not mount Radix until the pointer arrives', () => { - const { container } = render( - - - - ) - - // The idle wrapper is present; no Radix trigger has been created. - expect(container.querySelector('[data-slot="tooltip-idle"]')).toBeTruthy() - expect(container.querySelector('[data-slot="tooltip-trigger"]')).toBeNull() - }) -}) diff --git a/apps/desktop/src/components/ui/tooltip.tsx b/apps/desktop/src/components/ui/tooltip.tsx index a28478949f38..fe16e3b97cfc 100644 --- a/apps/desktop/src/components/ui/tooltip.tsx +++ b/apps/desktop/src/components/ui/tooltip.tsx @@ -108,53 +108,14 @@ interface TipProps extends Omit(null) - if (!label) { return <>{children} } - if (!armed) { - // `display: contents` so this wrapper never affects layout — the child - // participates in its parent's box exactly as it did before. - return ( - { - suppressNonKeyboardFocusOpen(event) - - if (!event.defaultPrevented) { - setArmed('focus') - } - }} - onPointerEnter={() => setArmed('pointer')} - style={{ display: 'contents' }} - > - {children} - - ) - } - - // `defaultOpen` is required, not incidental: the pointerenter/focus that - // armed this has ALREADY fired, so Radix's own trigger handlers never see it - // and the tip would mount silently closed. Arming IS the hover, so open with - // it — Radix owns every subsequent open/close from here (pointerleave, blur, - // escape, pointerdown) exactly as before. return ( - + {children} {label}