From 96fd2752ff9371ad9dfc104d271adfd81a06b8e8 Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 2 Dec 2024 11:56:04 +0100 Subject: [PATCH] Fix title bar hard to drag-and-move, closes #1 --- .../src/components/WindowButtons.tsx | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/apps/readest-app/src/components/WindowButtons.tsx b/apps/readest-app/src/components/WindowButtons.tsx index 644f982b..e8da0093 100644 --- a/apps/readest-app/src/components/WindowButtons.tsx +++ b/apps/readest-app/src/components/WindowButtons.tsx @@ -12,6 +12,24 @@ interface WindowButtonsProps { onClose?: () => void; } +interface WindowButtonProps { + id: string; + onClick: () => void; + ariaLabel: string; + children: React.ReactNode; +} + +const WindowButton: React.FC = ({ onClick, ariaLabel, id, children }) => ( + +); + const WindowButtons: React.FC = ({ className, headerRef, @@ -27,11 +45,7 @@ const WindowButtons: React.FC = ({ const handleMouseDown = async (e: MouseEvent) => { const target = e.target as HTMLElement; - if (target !== e.currentTarget) { - return; - } - - if (target.closest('#exclude-title-bar-mousedown')) { + if (target.closest('.window-button') || target.closest('#exclude-title-bar-mousedown')) { return; } @@ -83,45 +97,30 @@ const WindowButtons: React.FC = ({ )} > {showMinimize && ( - + )} {showMaximize && ( - + )} {showClose && ( - + )} );