Fix window drag bounds - #414
Merged
AllTerrainDeveloper merged 2 commits intoJul 24, 2026
Merged
Conversation
…ottom edges (WordPress#406)" This reverts commit 3222c61.
…rgins - Define a 40px constant to ensure a clickable title bar area is always accessible. - Introduce utility to prevent windows from being dragged completely off-screen, allowing them to bleed off the left, right, and bottom edges while strictly locking the top edge. - Update to use for floating window movements within the desktop view. - Refactor in the window manager to smoothly recover and pull stranded off-screen windows back into bounds during browser viewport resizes. - Add robust unit test coverage in to verify clamping constraints and pointer move bounding logic.
CookieDarb
marked this pull request as ready for review
July 24, 2026 12:27
AllTerrainDeveloper
approved these changes
Jul 24, 2026
AllTerrainDeveloper
left a comment
Collaborator
There was a problem hiding this comment.
WOAH! It feels amazing. It's very clean and clever! Thank you! ❤️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Closes #404
Allows windows to be dragged partially off-screen without losing access to them, and smoothly recovers stranded windows during browser resizes.
Why?
This allows to replicate how macOS and Windows naturally handle desktop boundaries: allowing users to push large windows partially out of the way to clear visual space.
Previously, floating windows could be dragged completely off-screen and lost. A prior attempt to fix this (PR #406) strictly trapped windows inside the viewport, which felt a bit restrictive. Additionally, making the browser window smaller would leave floating windows completely stranded outside the visible desktop area with no way to retrieve them without refresh or making the browser window large.
How?
src/window/constants.ts:GRAB_MARGINconstant to ensure a minimum clickable grab area is always maintained.src/window/pointer.ts:clampWindowPosition()to let windows bleed off the left, right, and bottom edges, stopping only when just 40px of the title bar remains visible. The top edge strictly locks at0.handleDragStart()to enforce these new boundaries during drag moves.src/window-manager/index.ts:reflowStatefulWindows()to include standard floating windows. If a browser resize leaves a window stranded off-screen, it smoothly pulls it back into the 40px grab area.tests/vitest/drag-unstate.test.ts:Testing Instructions
Screencast
Before
Screen.Recording.2026-07-24.at.5.23.53.PM.mov
After
Screen.Recording.2026-07-24.at.5.31.39.PM.mov
Use of AI Tools
AI assistance: Yes
Tool(s): Antigravity
Model(s): Gemini and Claude
Used for: Reviewing the existing implementation and suggesting the changes. Final decisions and edits were made by me.