Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panel onResize not called if there is no onLayout #161

Merged
merged 2 commits into from
Jun 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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