From f903afa24b3624ce55b96ea005c981eee65121f7 Mon Sep 17 00:00:00 2001 From: Christopher Ling <145088109+christopher-ling@users.noreply.github.com> Date: Sun, 21 Dec 2025 22:58:26 -0500 Subject: [PATCH 1/3] Update src/hoc/WindowWrapper.jsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/hoc/WindowWrapper.jsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/hoc/WindowWrapper.jsx b/src/hoc/WindowWrapper.jsx index 390bc11..3977baf 100644 --- a/src/hoc/WindowWrapper.jsx +++ b/src/hoc/WindowWrapper.jsx @@ -123,12 +123,22 @@ const WindowWrapper = (Component, windowKey) => { { selector: '.resize-corner-tl', edge: 'top-left' }, ]; + const listeners = []; + edges.forEach(({ selector, edge }) => { const handle = el.querySelector(selector); if (handle) { - handle.addEventListener('mousedown', (e) => handleMouseDown(e, edge)); + const listener = (e) => handleMouseDown(e, edge); + handle.addEventListener('mousedown', listener); + listeners.push({ handle, listener }); } }); + + return () => { + listeners.forEach(({ handle, listener }) => { + handle.removeEventListener('mousedown', listener); + }); + }; }, [windowKey, focusWindow, resizeWindow]); From b917df7fc73f71115e87352c483e1c4d4d1a9410 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Dec 2025 03:58:50 +0000 Subject: [PATCH 2/3] Initial plan From 96dcac2e75102bb60e7674aeaf70e159f03a3122 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Dec 2025 04:01:50 +0000 Subject: [PATCH 3/3] Extract window size constants to improve maintainability Co-authored-by: christopher-ling <145088109+christopher-ling@users.noreply.github.com> --- src/constants/index.js | 6 +++++- src/hoc/WindowWrapper.jsx | 13 +++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/constants/index.js b/src/constants/index.js index 0298e9f..e892787 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -492,6 +492,10 @@ export const locations = { const INITIAL_Z_INDEX = 1000; +// Minimum window dimensions for resizing +const MIN_WINDOW_WIDTH = 300; +const MIN_WINDOW_HEIGHT = 200; + const WINDOW_CONFIG = { finder: { isOpen: false, zIndex: INITIAL_Z_INDEX, data: null, isMinimized: false, width: null, height: null }, contact: { isOpen: false, zIndex: INITIAL_Z_INDEX, data: null, isMinimized: false, width: null, height: null }, @@ -503,4 +507,4 @@ const WINDOW_CONFIG = { imgfile: { isOpen: false, zIndex: INITIAL_Z_INDEX, data: null, isMinimized: false, width: null, height: null }, }; -export { INITIAL_Z_INDEX, WINDOW_CONFIG }; \ No newline at end of file +export { INITIAL_Z_INDEX, WINDOW_CONFIG, MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT }; \ No newline at end of file diff --git a/src/hoc/WindowWrapper.jsx b/src/hoc/WindowWrapper.jsx index 3977baf..6ecbe7e 100644 --- a/src/hoc/WindowWrapper.jsx +++ b/src/hoc/WindowWrapper.jsx @@ -3,6 +3,7 @@ import { useGSAP } from "@gsap/react"; import { useLayoutEffect, useRef, useState } from "react" import gsap from "gsap"; import { Draggable } from "gsap/Draggable"; +import { MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT } from "#constants"; /** * Higher-order component that wraps a window-like component with @@ -79,20 +80,20 @@ const WindowWrapper = (Component, windowKey) => { let newTop = startTop; if (edge.includes('right')) { - newWidth = Math.max(300, startWidth + (e.clientX - startX)); + newWidth = Math.max(MIN_WINDOW_WIDTH, startWidth + (e.clientX - startX)); } if (edge.includes('left')) { const delta = e.clientX - startX; - newWidth = Math.max(300, startWidth - delta); - if (newWidth > 300) newLeft = startLeft + delta; + newWidth = Math.max(MIN_WINDOW_WIDTH, startWidth - delta); + if (newWidth > MIN_WINDOW_WIDTH) newLeft = startLeft + delta; } if (edge.includes('bottom')) { - newHeight = Math.max(200, startHeight + (e.clientY - startY)); + newHeight = Math.max(MIN_WINDOW_HEIGHT, startHeight + (e.clientY - startY)); } if (edge.includes('top')) { const delta = e.clientY - startY; - newHeight = Math.max(200, startHeight - delta); - if (newHeight > 200) newTop = startTop + delta; + newHeight = Math.max(MIN_WINDOW_HEIGHT, startHeight - delta); + if (newHeight > MIN_WINDOW_HEIGHT) newTop = startTop + delta; } el.style.width = `${newWidth}px`;