PreviewTrigger popover renders unpositioned in the top-left corner after a fast sweep across several triggers
Provide a general summary of the issue here
Right after one PreviewTrigger preview has closed, sweeping the pointer quickly across several other triggers can open the next preview unpositioned: it renders in the top-left corner of the viewport (position: fixed; top: 0; left: 0, no data-placement) until its trigger is hovered again. Reproduced with a bare PreviewTrigger in react-aria-components 1.21.1; a screen recording and a minimal reproduction are below.
Expected Behavior?
A PreviewTrigger popover only renders once it is positioned next to its trigger, or not at all.
Current Behavior
After one preview has just closed, sweeping the pointer quickly across several PreviewTriggers and stopping just beside the last one sometimes opens that trigger's popover unpositioned:
- It renders at
position: fixed; top: 0; left: 0(the fallback style fromuseOverlayPositionwhen it has no position yet), with nodata-placement. - It stays in the corner until its trigger is hovered again, and then jumps into place.
- Occasionally it doesn't close at all until the trigger is hovered again.
It only reproduces with a real mouse. Synthetic pointer events (user-event, and PointerEvents dispatched by script) didn't reproduce it in our tests. A screen recording is attached.
Possible Solution
A guess: the warm-up path (the next preview opens immediately while warm, with shouldSkipAnimation) seems to open the popover in a way where updatePosition doesn't run, or bails out, until the trigger fires hover events again.
As a workaround we hide the popover until it has a placement:
:not([data-placement]) { visibility: hidden; }Context
We use PreviewTrigger for info icons in a list of statistics rows, one trigger per row. Moving the mouse down the list is enough to hit it now and then.
Side note: PreviewTrigger replaces its trigger's style prop (with its own WebkitUserDrag / WebkitTouchCallout) instead of merging it, so inline styles on the trigger Button are silently dropped. That's why the reproduction styles the button with a class.
️ Steps to Reproduce
import { Button, Popover, PreviewTrigger } from "react-aria-components";
function Row({ label }: { label: string }) {
return (
<div style={{ display: "flex", justifyContent: "space-between", width: 240 }}>
<span>{label}</span>
<PreviewTrigger delay={300}>
<Button aria-label={label} className="repro-trigger">i</Button>
<Popover
aria-label={label}
offset={10}
style={{ background: "#111827", color: "white", padding: 12, width: 220 }}
>
<strong>{label}</strong>
<ul>
<li><a href="#a" style={{ color: "white" }}>First link</a></li>
<li><a href="#b" style={{ color: "white" }}>Second link</a></li>
</ul>
</Popover>
</PreviewTrigger>
</div>
);
}
export function App() {
return (
<div style={{ display: "grid", gap: 4, padding: "120px 0 0 400px" }}>
<style>
{".repro-trigger { width: 24px; height: 24px; background: #e5e7eb; border: 1px solid #9ca3af; border-radius: 4px; }"}
</style>
{["Row 1", "Row 2", "Row 3", "Row 4", "Row 5", "Row 6"].map((label) => (
<Row key={label} label={label} />
))}
</div>
);
}- Hover a trigger until its preview opens, then move away so it closes.
- Straight after, sweep the pointer quickly down over the next few triggers (about 70ms on each), and stop just below the last one, not on it.
- Sometimes the last trigger's popover appears in the top-left corner of the viewport. Hovering that trigger again moves it into place.
It may take a few tries.
https://github.com/user-attachments/assets/017b07c0-968b-493e-b561-5ae95bccba42
Version
react-aria-components 1.21.1 (react-aria 3.52.1, react 19.2.7)
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
macOS 27.0
Your Company/Team
No response
Tracking Issue
No response
Source: adobe/react-spectrum