Skip to content

Commit

Permalink
Fix onDragging regression (#391)
Browse files Browse the repository at this point in the history
Resolves #388
  • Loading branch information
bvaughn authored Aug 21, 2024
1 parent 072c116 commit adc9038
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import styles from "./ResizeHandle.module.css";

export function ResizeHandle({
className = "",
collapsed = false,
id,
}: {
className?: string;
collapsed?: boolean;
id?: string;
}) {
return (
Expand Down
23 changes: 21 additions & 2 deletions packages/react-resizable-panels/src/PanelResizeHandle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,32 @@ describe("PanelResizeHandle", () => {
expect(onDraggingLeft).toHaveBeenCalledWith(true);

expect(cursorUtils.resetGlobalCursorStyle).not.toHaveBeenCalled();
expect(cursorUtils.setGlobalCursorStyle).toHaveBeenCalledTimes(1);
expect(cursorUtils.setGlobalCursorStyle).toHaveBeenCalled();

onDraggingLeft.mockReset();

act(() => {
dispatchPointerEvent("pointermove", leftElement);
});
expect(onDraggingLeft).not.toHaveBeenCalled();

act(() => {
dispatchPointerEvent("pointerup", leftElement);
});
expect(onDraggingLeft).toHaveBeenCalledTimes(1);
expect(onDraggingLeft).toHaveBeenCalledWith(false);

onDraggingLeft.mockReset();

act(() => {
dispatchPointerEvent("pointermove", leftElement);
});
expect(onDraggingLeft).not.toHaveBeenCalled();

act(() => {
root.unmount();
});

expect(cursorUtils.resetGlobalCursorStyle).toHaveBeenCalled();
expect(cursorUtils.setGlobalCursorStyle).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function handlePointerMove(event: PointerEvent) {

// Edge case (see #340)
// Detect when the pointer has been released outside an iframe on a different domain
if (event.buttons === 0) {
if (isPointerDown && event.buttons === 0) {
isPointerDown = false;

updateResizeHandlerStates("up", event);
Expand Down

0 comments on commit adc9038

Please sign in to comment.