Skip to content

dragbound fixes#13

Merged
gfazioli merged 4 commits intomasterfrom
dragbound-fixes
Jan 30, 2026
Merged

dragbound fixes#13
gfazioli merged 4 commits intomasterfrom
dragbound-fixes

Conversation

@gfazioli
Copy link
Owner

@gfazioli gfazioli commented Jan 30, 2026

🌟 [feat] Implemented a suite of improvements to the Window component, adding a fullSizeResizeHandles prop that enabled full-size handles when collapsed, and updated the drag logic to use the actual window height in collapsed mode for accurate bounds.

Added collapsed state handling to the drag hooks, tightening bounds calculations and preventing out-of-bounds movement. Fixed rendering glitches of resize handles when the window was collapsed, ensuring consistent visual behavior. Refactored the resize handle rendering logic to be more robust and easier to maintain. These changes enhanced user experience by providing smoother resizing and more reliable drag behavior in collapsed windows.

  • 🚀 feat(hooks): add collapsed state handling to window drag bounds
  • 🚀 feat: use actual window height when collapsed in drag logic
  • 🚀 feat(Window): add fullSizeResizeHandles prop
  • 🐛 fix: Adjust resize handle rendering when collapsed

- Expose `isCollapsed` from `useMantineWindow`
- Pass `isCollapsed` to `useWindowDrag`
- Use header height (40px) for drag bounds when window is collapsed
- Improves dragging behavior for collapsed windows
- Add `windowRef` to `useMantineWindow` and `useWindowDrag` options
- Update drag bounds calculation to use measured height from the DOM
- Improves window dragging accuracy when collapsed
- Introduce boolean prop to make side resize handles span full window edges.
- Update docs, demos, and stories to showcase new behavior.
- Adjust CSS to apply full-size handles when enabled.
- Ensure resize handles are only rendered when the window is not collapsed
- Horizontal resize handles remain available even when the window is collapsed
- Clarify comments to reflect new conditional logic for better maintainability
Copilot AI review requested due to automatic review settings January 30, 2026 15:21
@gfazioli gfazioli merged commit 628c851 into master Jan 30, 2026
5 checks passed
@gfazioli gfazioli deleted the dragbound-fixes branch January 30, 2026 15:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves window dragging/resizing behavior when the window is collapsed and adds a new option to make resize handles span the full edge for easier interaction.

Changes:

  • Update drag-bounds calculations to use the window’s actual rendered height when collapsed.
  • Add fullSizeResizeHandles prop and apply it to side resize handles (with supporting CSS).
  • Add Storybook/docs demos and configurator support for the new resize-handle behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
package/src/hooks/use-window-drag.ts Uses DOM-measured height when collapsed to compute drag constraints.
package/src/hooks/use-mantine-window.ts Passes collapsed state and windowRef into drag hook.
package/src/Window.tsx Adds fullSizeResizeHandles prop and adjusts handle rendering for collapsed state.
package/src/Window.module.css Implements full-edge side handle styling via data-full-size.
package/src/Window.story.tsx Adds Storybook stories showcasing full-size handles.
docs/docs.mdx Documents the new fullSizeResizeHandles behavior.
docs/demos/index.ts Exports the new demo entry.
docs/demos/Window.demo.fullSizeHandles.tsx Adds a docs demo for full-size resize handles.
docs/demos/Window.demo.configurator.tsx Adds fullSizeResizeHandles to the configurator controls.

Comment on lines +45 to +49
if (isCollapsed && windowRef.current) {
// Get the actual rendered height of the window element
const rect = windowRef.current.getBoundingClientRect();
effectiveHeight = rect.height;
}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getBoundingClientRect() is called inside applyBounds, which runs on every drag move while collapsed. This can trigger layout/reflow repeatedly and hurt drag performance. Consider measuring the collapsed height once (e.g., on drag start or in a layout effect when isCollapsed changes) and caching it in a ref/state for use during the drag instead of reading layout on each move.

Copilot uses AI. Check for mistakes.
const applyBounds = useCallback(
(newX: number, newY: number): { x: number; y: number } => {
// When collapsed, use the actual measured height from the DOM
// This ensures we account for all borders, paddings, and margins
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getBoundingClientRect() includes padding and borders, but not margins. The comment is misleading and should be adjusted to reflect what is actually measured.

Suggested change
// This ensures we account for all borders, paddings, and margins
// This uses the element's rendered box height (including padding and borders, excluding margins)

Copilot uses AI. Check for mistakes.
Comment on lines +430 to +436
data-full-size={fullSizeResizeHandles || undefined}
{...resizeHandlers.right}
{...getStyles('resizeHandleRight')}
/>
<Box
data-resize-handle
data-full-size={fullSizeResizeHandles || undefined}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With fullSizeResizeHandles enabled, the left/right handle CSS insets by --window-handle-square (to avoid corner handles). When the window is collapsed (and corner handles are not rendered), this inset can significantly reduce the effective hit area (often smaller than the default 40px handle). Consider only applying the corner-avoidance inset when corner handles are actually present (e.g., resizable === 'both' && !isCollapsed), while keeping true full-height handles in collapsed or non-corner modes.

Suggested change
data-full-size={fullSizeResizeHandles || undefined}
{...resizeHandlers.right}
{...getStyles('resizeHandleRight')}
/>
<Box
data-resize-handle
data-full-size={fullSizeResizeHandles || undefined}
data-full-size={
fullSizeResizeHandles && resizable === 'both' && !isCollapsed ? true : undefined
}
{...resizeHandlers.right}
{...getStyles('resizeHandleRight')}
/>
<Box
data-resize-handle
data-full-size={
fullSizeResizeHandles && resizable === 'both' && !isCollapsed ? true : undefined
}

Copilot uses AI. Check for mistakes.
Comment on lines +425 to +441
{/* Horizontal handles - always available for horizontal resize even when collapsed */}
{resizable !== 'none' && (resizable === 'horizontal' || resizable === 'both') && (
<>
<Box
data-resize-handle
data-full-size={fullSizeResizeHandles || undefined}
{...resizeHandlers.right}
{...getStyles('resizeHandleRight')}
/>
<Box
data-resize-handle
data-full-size={fullSizeResizeHandles || undefined}
{...resizeHandlers.left}
{...getStyles('resizeHandleLeft')}
/>
</>
)}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New behaviors are introduced (collapsed drag bounds using measured height, and fullSizeResizeHandles affecting handle layout), but there are no corresponding unit tests. Please add tests to cover at least: (1) horizontal handles remain available when collapsed, (2) data-full-size is applied when fullSizeResizeHandles is true, and (3) drag bounds calculations differ when collapsed vs expanded.

Copilot generated this review using guidance from repository custom instructions.
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.

1 participant