From 96efcb12c7ecb5083168c4e123aded4b4dd63b50 Mon Sep 17 00:00:00 2001 From: spencrmartin Date: Wed, 12 Nov 2025 14:18:27 -0500 Subject: [PATCH] fix: improve child webviewer window positioning and movement tracking - Add focus/blur event listeners to trigger bounds updates when window becomes active - Enhance bounds tracking system to better handle main window movement - Improve responsiveness of child window positioning during window operations - Add proper cleanup for new event listeners - Maintain existing main process move/resize event handlers for comprehensive tracking This should fix the issue where child webviewer windows drift away when moving the main window. --- ui/desktop/src/components/WebViewer.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/desktop/src/components/WebViewer.tsx b/ui/desktop/src/components/WebViewer.tsx index 4f3af2ecb7..51fb9bfacc 100644 --- a/ui/desktop/src/components/WebViewer.tsx +++ b/ui/desktop/src/components/WebViewer.tsx @@ -316,7 +316,7 @@ export function WebViewer({ }; }, [childWindowCreated, webViewerContext, unifiedSidecarContext]); - // Update child window bounds when container resizes (throttled) + // Update child window bounds when container resizes or window moves (throttled) useEffect(() => { if (!childWindowCreated || !containerRef.current) return; @@ -358,9 +358,11 @@ export function WebViewer({ const resizeObserver = new ResizeObserver(throttledUpdateBounds); resizeObserver.observe(containerRef.current); - // Listen for window resize and scroll events + // Listen for window resize, scroll, and focus events window.addEventListener('resize', throttledUpdateBounds); window.addEventListener('scroll', throttledUpdateBounds); + window.addEventListener('focus', throttledUpdateBounds); + window.addEventListener('blur', throttledUpdateBounds); // Use MutationObserver with broader scope to catch drag operations const mutationObserver = new MutationObserver((mutations) => { @@ -469,6 +471,8 @@ export function WebViewer({ mutationObserver.disconnect(); window.removeEventListener('resize', throttledUpdateBounds); window.removeEventListener('scroll', throttledUpdateBounds); + window.removeEventListener('focus', throttledUpdateBounds); + window.removeEventListener('blur', throttledUpdateBounds); }; }, [childWindowCreated]);