mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-08-28 14:06:36 +00:00
fix(markdown-editor): dismiss table hover-grips on window resize
Unlike the link and image handles, TableHandles registered only scroll (and, now, editor update) invalidation — never resize. Resizing the window reflowed the table but left the fixed-position grips glued to their old coordinates, detached from the table, until the next hover. Mirror the sibling handles and drop the target on resize too. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
6c3a011fe2
commit
b4fb572efa
@@ -339,10 +339,11 @@ function useTableHandles(editor: Editor): TableHandlesController {
|
||||
|
||||
document.addEventListener('mousemove', handleMove);
|
||||
|
||||
// A grip captured before a scroll or an edit points at a now-shifted position. Scroll moves it off the
|
||||
// table visually; a doc edit shifts every position after it, so a menu action would resolve the stale
|
||||
// cellPos against the current doc (wrong row/column, or an out-of-bounds RangeError in the header
|
||||
// selector). Drop the target in both cases — it reappears on the next hover.
|
||||
// A grip captured before a scroll, resize, or edit points at a now-shifted position: scroll/resize move it
|
||||
// off the table visually, and a doc edit shifts every position after it, so a menu action would resolve
|
||||
// the stale cellPos against the current doc (wrong row/column, or an out-of-bounds RangeError in the
|
||||
// header selector). Drop the target in every case — it reappears on the next hover. (link/image handles
|
||||
// already dismiss on resize; TableHandles missed it and its grips detached from the table on window resize.)
|
||||
const scrollParent = getEditorScrollParent(dom);
|
||||
|
||||
const dropStaleTarget = () => {
|
||||
@@ -353,12 +354,14 @@ function useTableHandles(editor: Editor): TableHandlesController {
|
||||
};
|
||||
|
||||
scrollParent.addEventListener('scroll', dropStaleTarget, { passive: true });
|
||||
window.addEventListener('resize', dropStaleTarget);
|
||||
editor.on('update', dropStaleTarget);
|
||||
|
||||
return () => {
|
||||
cancelClear();
|
||||
document.removeEventListener('mousemove', handleMove);
|
||||
scrollParent.removeEventListener('scroll', dropStaleTarget);
|
||||
window.removeEventListener('resize', dropStaleTarget);
|
||||
editor.off('update', dropStaleTarget);
|
||||
};
|
||||
}, [editor]);
|
||||
|
||||
Reference in New Issue
Block a user