From 26ea1e70c92f0fb59cd66e817d6d284b2e0568f5 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 28 Apr 2026 19:25:30 -0300 Subject: client: hoverable-tooltip: use brains if not hovering first rect --- src/static/js/client/hoverable-tooltip.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/static/js/client') diff --git a/src/static/js/client/hoverable-tooltip.js b/src/static/js/client/hoverable-tooltip.js index f19517ad..99fe14f6 100644 --- a/src/static/js/client/hoverable-tooltip.js +++ b/src/static/js/client/hoverable-tooltip.js @@ -671,7 +671,22 @@ export function positionTooltipFromHoverableWithBrains(hoverable) { const {numBaselineRects, idealBaseline: baselineRect} = opportunities; if (baselineRect.contains(tooltipRect)) { - return; + // ...unless hovering over a rectangle besides the hoverable's first. + // An element has multiple rectangles if it's an inline element that + // has wrapped across to the next line. + + const hoverableClientRects = + Array.from(hoverable.getClientRects()) + .map(rect => WikiRect.fromRect(rect)); + + const mouseRect = WikiRect.fromMouse(); + + const hoverableClientRectIndex = + hoverableClientRects.findIndex(rect => rect.contains(mouseRect)); + + if (hoverableClientRectIndex <= 0) { + return; + } } const tryDirection = (dir1, dir2, i) => { -- cgit 1.3.0-6-gf8a5