From b4fb572efab605337e4dc85e9a88dd4809cc46fa Mon Sep 17 00:00:00 2001 From: Sergey Kozyrenko Date: Tue, 7 Jul 2026 19:44:36 +0700 Subject: [PATCH] fix(markdown-editor): dismiss table hover-grips on window resize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../markdown-editor/markdown-editor-table-handles.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/shared/markdown-editor/markdown-editor-table-handles.tsx b/frontend/src/components/shared/markdown-editor/markdown-editor-table-handles.tsx index 15ddb2b5..b8298a55 100644 --- a/frontend/src/components/shared/markdown-editor/markdown-editor-table-handles.tsx +++ b/frontend/src/components/shared/markdown-editor/markdown-editor-table-handles.tsx @@ -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]);