EditorView.posAtCoords can throw TypeError: Cannot read properties of undefined (reading 'top') when the editor content reports **no client rects** for the queried position (e.g. the editor, or an ancestor, is `display:none` / detached / mid-layout at the moment of the call).
Root cause seems to be in InlineCoordsScan.scan, when the scanned positions yield no client rectangles at all, none of above, below or closestRect are ever assigned:
if (!closestRect) { let side = above && (!below || (this.y - above.bottom < below.top - this.y)) ? above : below; this.y = (side.top + side.bottom) / 2; // <-- side is undefined โ throws return this.scan(positions, getRects /*, true */); }
We encountered this error via the hoverTooltip plugin, which on hover schedules a delayed startHover which synchronously calls view.posAtCoords(lastMove). If the editor loses its client rects within that delay - examples a tile that re-renders/collapses/scrolls out - the coordinate scan returns an empty list thus the error is thrown.
Since all of this happens in a span of about 300 ms, it is really hard to provide a reproducible example, but a suggested fix would be for the scan to handle no client rectangles found.