Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

chore(Resizable): restore mocks after each resizable-slot case, plus two source cleanups (#10032)

Christopher Chedeau267399819250
diff --git a/.changeset/resizable-slot-test-cleanup.md b/.changeset/resizable-slot-test-cleanup.md
new file mode 100644
index 0000000000..3e38317475
--- /dev/null
+++ b/.changeset/resizable-slot-test-cleanup.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[chore] Internal cleanups in SideNav and in how a resize handle finds its panel: a source comment that only restated the line after it goes, and one lookup function replaces two. No behavior change.
+
+@vjeux
diff --git a/packages/core/src/Resizable/resizablePane.ts b/packages/core/src/Resizable/resizablePane.ts
index 18beea58ea..b2591e36ae 100644
--- a/packages/core/src/Resizable/resizablePane.ts
+++ b/packages/core/src/Resizable/resizablePane.ts
@@ -56,23 +56,14 @@ export function watchResizablePanes(listener: () => void): () => void {
* The pane a resize handle resizes: the lent LayoutPanel just before it, or
* just after it when the region is reversed.
*/
-export function resizablePaneBeside(
- handle: Element,
- side: 'before' | 'after',
-): ResizablePane | null {
- const sibling =
- side === 'before'
- ? handle.previousElementSibling
- : handle.nextElementSibling;
- return sibling == null ? null : (lent.get(sibling) ?? null);
-}
-
-/** The lent panel a handle sizes: before it, or after it when reversed. */
export function resizablePaneFor(
handle: Element,
isReversed: boolean,
): ResizablePane | null {
- return resizablePaneBeside(handle, isReversed ? 'after' : 'before');
+ const sibling = isReversed
+ ? handle.nextElementSibling
+ : handle.previousElementSibling;
+ return sibling == null ? null : (lent.get(sibling) ?? null);
}
/**
diff --git a/packages/core/src/Resizable/resizableSlot.test.tsx b/packages/core/src/Resizable/resizableSlot.test.tsx
index 575942a36a..a3d026c39d 100644
--- a/packages/core/src/Resizable/resizableSlot.test.tsx
+++ b/packages/core/src/Resizable/resizableSlot.test.tsx
@@ -70,6 +70,7 @@ const separator = () => screen.getByRole('separator', {name: 'Resize pane'});
afterEach(() => {
latest = undefined;
localStorage.clear();
+ vi.restoreAllMocks();
});
describe("the `resizable` slot takes useResizable's output directly", () => {
diff --git a/packages/core/src/SideNav/SideNav.tsx b/packages/core/src/SideNav/SideNav.tsx
index 2d50e8ff15..78f1483b02 100644
--- a/packages/core/src/SideNav/SideNav.tsx
+++ b/packages/core/src/SideNav/SideNav.tsx
@@ -621,7 +621,6 @@ export function SideNav({
onCollapseChange: onCollapsedChange,
});
- // The region that sizes the rail: the caller's, or SideNav's own.
const region = ownerRegion ?? resizableHook;
const collapsed = region.isCollapsed;