Skip to content

Commit

Permalink
Better handle possible null DragState (edge case)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Dec 10, 2023
1 parent c566bd8 commit ddb4a52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/react-resizable-panels/src/PanelGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ function PanelGroupWithForwardedRef({
event,
dragHandleId,
direction,
dragState!,
dragState,
keyboardResizeBy
);
if (delta === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function calculateDeltaPercentage(
event: ResizeEvent,
dragHandleId: string,
direction: Direction,
initialDragState: DragState,
initialDragState: DragState | null,
keyboardResizeBy: number | null
): number {
if (isKeyDown(event)) {
Expand Down Expand Up @@ -47,6 +47,10 @@ export function calculateDeltaPercentage(

return movement;
} else {
if (initialDragState == null) {
return 0;
}

return calculateDragOffsetPercentage(
event,
dragHandleId,
Expand Down

0 comments on commit ddb4a52

Please sign in to comment.