Skip to content

Commit

Permalink
Don't cancel resize operations when exiting the window (#44)
Browse files Browse the repository at this point in the history
Only cancel when a "mouseup" (or "touchend") event is fired.
  • Loading branch information
bvaughn authored Dec 29, 2022
2 parents db03084 + ca75513 commit a186169
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/react-resizable-panels/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 0.0.23
* [#40](https://github.com/bvaughn/react-resizable-panels/issues/40): Add optional `maxSize` prop to `Panel`.
* [#42](https://github.com/bvaughn/react-resizable-panels/issues/42): Don't cancel resize operations when exiting the window. Only cancel when a `"mouseup"` (or `"touchend"`) event is fired.

## 0.0.22
* Replaced the `"ew-resize"` and `"ns-resize"` cursor style with `"col-resize"` and `"row-resize"`.
Expand Down
8 changes: 4 additions & 4 deletions packages/react-resizable-panels/src/PanelResizeHandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ export default function PanelResizeHandle({
};

document.body.addEventListener("contextmenu", stopDraggingAndBlur);
document.body.addEventListener("mouseleave", stopDraggingAndBlur);
document.body.addEventListener("mousemove", onMove);
document.body.addEventListener("touchmove", onMove);
document.body.addEventListener("mouseup", stopDraggingAndBlur);
window.addEventListener("mouseup", stopDraggingAndBlur);
window.addEventListener("touchend", stopDraggingAndBlur);

return () => {
document.body.style.cursor = "";

document.body.removeEventListener("contextmenu", stopDraggingAndBlur);
document.body.removeEventListener("mouseleave", stopDraggingAndBlur);
document.body.removeEventListener("mousemove", onMove);
document.body.removeEventListener("touchmove", onMove);
document.body.removeEventListener("mouseup", stopDraggingAndBlur);
window.removeEventListener("mouseup", stopDraggingAndBlur);
window.removeEventListener("touchend", stopDraggingAndBlur);
};
}, [direction, disabled, isDragging, resizeHandler, stopDraggingAndBlur]);

Expand Down

1 comment on commit a186169

@vercel
Copy link

@vercel vercel bot commented on a186169 Dec 29, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.