From c91536325f6686e24f65cf1b81ba1b346bc2066a Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Tue, 7 Jul 2026 22:44:04 +0400 Subject: [PATCH] fix: don't start window drag on interactive controls --- src/components/home-header.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/home-header.tsx b/src/components/home-header.tsx index 9f6a886..706b8f2 100644 --- a/src/components/home-header.tsx +++ b/src/components/home-header.tsx @@ -15,10 +15,15 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip"; const HOLD_MS = 150; const DRAG_THRESHOLD_PX = 3; -const isTextInputTarget = (target: EventTarget | null): boolean => { +// Any interactive control (buttons, links, inputs) must NOT start a window +// drag when pressed — otherwise the press-and-hold / drag-threshold logic below +// hands the pointer to the OS window-move loop and the control's click never +// fires (e.g. the "+ New" button needing a double-click, and the window +// un-maximizing on Windows). Mirrors the guard handleDoubleClick already uses. +const isInteractiveTarget = (target: EventTarget | null): boolean => { if (!(target instanceof Element)) return false; const el = target.closest( - "input, select, textarea, [contenteditable=''], [contenteditable='true']", + "button, a, [role='button'], input, select, textarea, [contenteditable=''], [contenteditable='true']", ); return el !== null; }; @@ -87,7 +92,7 @@ const HomeHeader = ({ const handlePointerDown = useCallback( (e: React.PointerEvent) => { if (e.button !== 0) return; - if (isTextInputTarget(e.target)) return; + if (isInteractiveTarget(e.target)) return; dragStartedRef.current = false; dragStartRef.current = { x: e.clientX, y: e.clientY }; @@ -133,8 +138,7 @@ const HomeHeader = ({ const handleDoubleClick = useCallback( (e: React.MouseEvent) => { - if (isTextInputTarget(e.target)) return; - if (e.target instanceof Element && e.target.closest("button")) return; + if (isInteractiveTarget(e.target)) return; clearHold(); void getCurrentWindow().toggleMaximize(); },