Skip to content

Commit d141168

Browse files
authored
fix: improve cell selection with fallback strategy for merged cells (#323)
1 parent 42851d6 commit d141168

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/input.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,11 @@ function cellUnderMouse(
288288
top: event.clientY,
289289
});
290290
if (!mousePos) return null;
291-
// Use `inside` position when available (when pointer is inside a node),
292-
// otherwise fall back to `pos`
293-
const pos = mousePos.inside >= 0 ? mousePos.inside : mousePos.pos;
294-
return cellAround(view.state.doc.resolve(pos));
291+
// Prefer `inside` position for better accuracy with merged cells (rowspan/colspan),
292+
// but fall back to `pos` if `inside` doesn't resolve to a valid cell
293+
let { inside, pos } = mousePos;
294+
return (
295+
(inside >= 0 && cellAround(view.state.doc.resolve(inside))) ||
296+
cellAround(view.state.doc.resolve(pos))
297+
);
295298
}

0 commit comments

Comments
 (0)