From 71a8cb2f441751f77c187960f789be677fd962ce Mon Sep 17 00:00:00 2001 From: Timur Sufiev Date: Wed, 6 Dec 2023 16:08:24 +0000 Subject: [PATCH] fix: resize should not fail when `dragState` is null Resolves #223 --- .../react-resizable-panels/src/PanelGroup.ts | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/react-resizable-panels/src/PanelGroup.ts b/packages/react-resizable-panels/src/PanelGroup.ts index 23000bb4e..b450f9e30 100644 --- a/packages/react-resizable-panels/src/PanelGroup.ts +++ b/packages/react-resizable-panels/src/PanelGroup.ts @@ -711,17 +711,19 @@ function PanelGroupWithForwardedRef({ const pivotIndices = determinePivotIndices(groupId, dragHandleId); - let delta = calculateDeltaPercentage( - event, - groupId, - dragHandleId, - direction, - dragState!, - { - percentage: keyboardResizeByPercentage, - pixels: keyboardResizeByPixels, - } - ); + let delta = dragState + ? calculateDeltaPercentage( + event, + groupId, + dragHandleId, + direction, + dragState, + { + percentage: keyboardResizeByPercentage, + pixels: keyboardResizeByPixels, + } + ) + : 0; if (delta === 0) { return; }