[Bug]: click(selector) silently misses when the element's center is outside the viewport
Affected component
ego-browser runtime or CLI
What happened?
click('#btn') resolved successfully, but the click never reached the button. The button's bounding rect straddled the bottom edge of the viewport:
- viewport height 846 px (
pageInfo()→h: 846) - button rect
y = 833.64, height = 32.5→ center aty ≈ 849.9, about 4 px outside the viewport
Capture-phase listeners showed ego dispatched mousedown/mouseup/click at (1472, 849) with target <html>: the events landed on the page background, the button's handler never ran, and click() returned success with no warning.
The element was partially visible, so a scrollIntoViewIfNeeded-style check considers it "in view" and never scrolls — but the click point (the element center) is outside the viewport, so the dispatch hits whatever sits at those coordinates, or nothing.
Steps to reproduce
1. Load a page with a button whose bounding rect is partially below the fold, with its center outside the viewport (e.g. rect y=833.6, height=32.5 on an 846 px viewport).
2. Call `await click('#btn')` in selector form (ego computes the element center itself).
3. Observe: capture-phase listeners record target `<html>` at the off-screen coordinates, the button's handler does not run, and the call resolves without any error or warning.Expected behavior
Scroll the element (or at least its click point) into view before dispatching — e.g. scrollIntoView({ block: 'center' }) — or clamp the coordinates / fail loudly when the click point lies outside the viewport. A click that silently lands on <html> while reporting success is the worst failure mode for an agent.
Version
ego-browser skill 1.2.3; ego lite 0.4.7.4
Environment
macOS 26.6.2 (Apple Silicon); agent-driven ego-browser heredocs
Logs or screenshots
Button state and delivered events from the repro:
{"btnCancel.disabled": false, "btnCancel.rect": {"x":1414,"y":833.640625,"w":117,"h":32.5}}
["mousedown -> HTML @1472,849","mouseup -> HTML @1472,849","click -> HTML @1472,849"]
Viewport at the time: `pageInfo()` → `{"w":1920,"h":846}`.Additional context
Workaround: call el.scrollIntoView({ block: 'center' }) via js() before click(), or click via DOM el.click().
Related event-fidelity report found in the same session: #349.
Before submitting
- I searched the existing issues and did not find a duplicate.
- I removed secrets and sensitive browsing data from this report.
Source: citrolabs/ego-lite