mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-07-11 07:13:43 +02:00
fix: don't start window drag on interactive controls
This commit is contained in:
@@ -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<HTMLDivElement>) => {
|
||||
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<HTMLDivElement>) => {
|
||||
if (isTextInputTarget(e.target)) return;
|
||||
if (e.target instanceof Element && e.target.closest("button")) return;
|
||||
if (isInteractiveTarget(e.target)) return;
|
||||
clearHold();
|
||||
void getCurrentWindow().toggleMaximize();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user