Skip to content

Improve draggable panel restoration on viewport resize#305

Merged
Edwardvaneechoud merged 1 commit intomainfrom
claude/fix-window-resize-panels-ORvL7
Feb 4, 2026
Merged

Improve draggable panel restoration on viewport resize#305
Edwardvaneechoud merged 1 commit intomainfrom
claude/fix-window-resize-panels-ORvL7

Conversation

@Edwardvaneechoud
Copy link
Copy Markdown
Owner

Summary

Enhanced the DraggablePanel component to intelligently handle panel state restoration when the viewport dimensions change between sessions. This prevents panels from being positioned off-screen or with incorrect dimensions after a browser resize.

Key Changes

  • Viewport dimension tracking: Save window.innerWidth and window.innerHeight when persisting panel state to detect viewport changes on next load
  • Smart resize detection: On mount, compare saved viewport dimensions with current dimensions to determine if a resize occurred
  • Three-path restoration logic:
    • No viewport info (legacy saved state): Reset to initial position and save new state with viewport info
    • Viewport changed: Apply smart resize calculation using saved viewport as reference to proportionally adjust panel position and size
    • Viewport unchanged: Restore saved state directly with validation constraints
  • Updated PanelState interface: Added optional savedViewportWidth and savedViewportHeight fields to track viewport at save time

Implementation Details

  • The smart resize logic reuses the existing handleWindowResizeSmartly() function by temporarily setting prevViewportWidth and prevViewportHeight to the saved dimensions
  • Maintains backward compatibility with existing saved states (gracefully handles missing viewport info)
  • Ensures panels remain visible and properly constrained within the new viewport dimensions
  • zIndex restoration is preserved across all restoration paths

When the page is first opened with a different viewport size than when the
panel state was saved, the smart resize logic is now applied to correctly
reposition panels. This ensures docked panels (left, right, top, bottom)
maintain their edge docking while proportionally repositioning non-docked
panels.

Changes:
- Store viewport dimensions (savedViewportWidth/Height) when saving panel state
- On mount, detect if viewport has changed since state was saved
- Apply smart resize logic when viewport changed to recalculate positions
- Reset to initial position for old saved states without viewport info

https://claude.ai/code/session_012kMcUfGHuCpMjK8hrZ6K2S
@netlify
Copy link
Copy Markdown

netlify bot commented Feb 4, 2026

Deploy Preview for flowfile-wasm ready!

Name Link
🔨 Latest commit c1d10f8
🔍 Latest deploy log https://app.netlify.com/projects/flowfile-wasm/deploys/69836304eb1a530007aee218
😎 Deploy Preview https://deploy-preview-305--flowfile-wasm.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Edwardvaneechoud Edwardvaneechoud merged commit 33bc7ef into main Feb 4, 2026
17 checks passed
@Edwardvaneechoud Edwardvaneechoud deleted the claude/fix-window-resize-panels-ORvL7 branch February 4, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants