Skip to content

Commit ae37deb

Browse files
committed
Support updates to either Group or Panel ids
1 parent 3be6031 commit ae37deb

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

lib/components/group/Group.test.tsx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { render } from "@testing-library/react";
22
import { beforeEach, describe, expect, test, vi } from "vitest";
3+
import { eventEmitter } from "../../global/mutableState";
34
import { moveSeparator } from "../../global/test/moveSeparator";
5+
import { assert } from "../../utils/assert";
46
import { setElementBoundsFunction } from "../../utils/test/mockBoundingClientRect";
57
import { Panel } from "../panel/Panel";
68
import { Separator } from "../separator/Separator";
79
import { Group } from "./Group";
8-
import { assert } from "../../utils/assert";
9-
import { eventEmitter } from "../../global/mutableState";
1010

1111
describe("Group", () => {
1212
test("changes to defaultProps or disableCursor should not cause Group to remount", () => {
@@ -47,6 +47,36 @@ describe("Group", () => {
4747
removeListener();
4848
});
4949

50+
test("should support updates to either Group or Panel ids", () => {
51+
const { rerender } = render(
52+
<Group id="a">
53+
<Panel id="a-a" />
54+
<Panel id="a-b" />
55+
</Group>
56+
);
57+
58+
rerender(
59+
<Group id="a">
60+
<Panel id="b-a" />
61+
<Panel id="b-b" />
62+
</Group>
63+
);
64+
65+
rerender(
66+
<Group id="b">
67+
<Panel id="b-a" />
68+
<Panel id="b-b" />
69+
</Group>
70+
);
71+
72+
rerender(
73+
<Group id="c">
74+
<Panel id="c-a" />
75+
<Panel id="c-b" />
76+
</Group>
77+
);
78+
});
79+
5080
describe("onLayoutChange", () => {
5181
beforeEach(() => {
5282
setElementBoundsFunction((element) => {

lib/global/utils/layoutsEqual.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export function layoutsEqual(a: Layout, b: Layout): boolean {
77
}
88

99
for (const id in a) {
10-
if (compareLayoutNumbers(a[id], b[id]) !== 0) {
10+
// Edge case: Panel id has been changed
11+
if (b[id] === undefined || compareLayoutNumbers(a[id], b[id]) !== 0) {
1112
return false;
1213
}
1314
}

0 commit comments

Comments
 (0)