Skip to content

Commit e6ec2f7

Browse files
FourWindffclaude
andcommitted
fix(diff): guard dblclick blank-area handler more carefully
- Only handle primary button (e.button === 0) - Skip INPUT/TEXTAREA/contentEditable to preserve double-click word selection - Narrow target type with instanceof instead of as-cast Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d2e628c commit e6ec2f7

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/components/ScrollingDiffView.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,12 +897,15 @@ export function ScrollingDiffView(props: ScrollingDiffViewProps) {
897897
// so the user doesn't see a brief blue flash on the last diff line.
898898
// Note: this fires on the second mousedown of the sequence — the
899899
// first mousedown of a double-click has detail === 1.
900-
if (e.detail >= 2) {
901-
const target = e.target as HTMLElement | null;
902-
if (!target?.closest('[data-line-type]')) {
903-
e.preventDefault();
904-
}
905-
}
900+
if (e.button !== 0 || e.detail < 2) return;
901+
const target = e.target;
902+
if (!(target instanceof Element)) return;
903+
if (
904+
target instanceof HTMLElement &&
905+
(target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable)
906+
)
907+
return;
908+
if (!target.closest('[data-line-type]')) e.preventDefault();
906909
}
907910

908911
function onMouseUp() {

0 commit comments

Comments
 (0)