Skip to content

Commit

Permalink
Merge pull request #161 from rijk/fix-localstorage-onresize
Browse files Browse the repository at this point in the history
Panel onResize not called if there is no onLayout
  • Loading branch information
bvaughn authored Jun 24, 2023
2 parents a87cdb6 + 3070e54 commit 7c64c9c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions packages/react-resizable-panels/src/PanelGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,24 +232,24 @@ function PanelGroupWithForwardedRef({
// Notify external code when sizes have changed.
useEffect(() => {
const { onLayout } = callbacksRef.current!;
if (onLayout) {
const { panels, sizes } = committedValuesRef.current;
const { panels, sizes } = committedValuesRef.current;

// Don't commit layout until all panels have registered and re-rendered with their actual sizes.
if (sizes.length > 0) {
// Don't commit layout until all panels have registered and re-rendered with their actual sizes.
if (sizes.length > 0) {
if (onLayout) {
onLayout(sizes);
}

const panelIdToLastNotifiedSizeMap =
panelIdToLastNotifiedSizeMapRef.current;
const panelIdToLastNotifiedSizeMap =
panelIdToLastNotifiedSizeMapRef.current;

// When possible, we notify before the next render so that rendering work can be batched together.
// Some cases are difficult to detect though,
// for example– panels that are conditionally rendered can affect the size of neighboring panels.
// In this case, the best we can do is notify on commit.
// The callPanelCallbacks() uses its own memoization to avoid notifying panels twice in these cases.
const panelsArray = panelsMapToSortedArray(panels);
callPanelCallbacks(panelsArray, sizes, panelIdToLastNotifiedSizeMap);
}
// When possible, we notify before the next render so that rendering work can be batched together.
// Some cases are difficult to detect though,
// for example– panels that are conditionally rendered can affect the size of neighboring panels.
// In this case, the best we can do is notify on commit.
// The callPanelCallbacks() uses its own memoization to avoid notifying panels twice in these cases.
const panelsArray = panelsMapToSortedArray(panels);
callPanelCallbacks(panelsArray, sizes, panelIdToLastNotifiedSizeMap);
}
}, [sizes]);

Expand Down

1 comment on commit 7c64c9c

@vercel
Copy link

@vercel vercel bot commented on 7c64c9c Jun 24, 2023

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.