Skip to content

Commit 75a1872

Browse files
fix(web): keep a frame parked beside the composer at its size across renders
A resize could grow a player in the margin beside the composer, but the next layout pass refitted the stored width against the rows above the composer and shrank it back. A positioned frame is now fitted against its own columns' floor; a fresh player still takes the rows every column has. Co-Authored-By: Claude Code <[email protected]>
1 parent d50d77b commit 75a1872

2 files changed

Lines changed: 35 additions & 4 deletions

File tree

‎apps/web/src/components/preview/previewMiniPlayerLayout.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,30 @@ describe("resolvePreviewMiniPlayerFrame", () => {
117117
expect(frame).toEqual({ x: 100, y: PREVIEW_MINI_PLAYER_EDGE_GAP, width: 602, height: 376 });
118118
});
119119

120+
it("keeps a tall frame parked beside the composer across layout passes", () => {
121+
// The frame an edge resize produced in the left margin, resolved again from
122+
// the stored width and position on the next render.
123+
const phone = { width: 390, height: 844 };
124+
const beside = { composer: { left: 300, right: 900, height: 300 } };
125+
const resized = resizePreviewMiniPlayer({
126+
start: { x: 12, y: 100, width: 240, height: 519 },
127+
direction: "east",
128+
delta: { x: 10, y: 0 },
129+
source: phone,
130+
container,
131+
obstacles: beside,
132+
});
133+
expect(
134+
resolvePreviewMiniPlayerFrame({
135+
width: resized.width,
136+
position: { x: resized.x, y: resized.y },
137+
source: phone,
138+
container,
139+
obstacles: beside,
140+
}),
141+
).toEqual(resized);
142+
});
143+
120144
it("never grows past the source's own rendered size", () => {
121145
expect(
122146
resolvePreviewMiniPlayerFrame({

‎apps/web/src/components/preview/previewMiniPlayerLayout.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,22 @@ function floorFor(
109109
: container.height;
110110
}
111111

112-
// The largest box guaranteed to fit somewhere: full width, and the rows above the composer.
112+
/**
113+
* The box a stored size is fitted into. A player with a position keeps the
114+
* rows its own columns have, so a tall frame parked beside the composer
115+
* survives the next layout pass; without one it takes the rows above the
116+
* composer, which every column has.
117+
*/
113118
const availableArea = (
114119
container: PreviewMiniPlayerSize,
115120
obstacles: PreviewMiniPlayerObstacles,
121+
span: HorizontalSpan | null,
116122
): PreviewMiniPlayerSize => ({
117123
width: container.width - PREVIEW_MINI_PLAYER_EDGE_GAP * 2,
118124
height:
119-
container.height -
120-
Math.max(0, obstacles.composer?.height ?? 0) -
125+
(span
126+
? floorFor(span, container, obstacles)
127+
: container.height - Math.max(0, obstacles.composer?.height ?? 0)) -
121128
PREVIEW_MINI_PLAYER_EDGE_GAP * 2,
122129
});
123130

@@ -240,7 +247,7 @@ export function resolvePreviewMiniPlayerFrame(input: {
240247
const size = fitPreviewMiniPlayerWidth(
241248
width ?? defaultPreviewMiniPlayerWidth(source),
242249
source,
243-
availableArea(container, obstacles),
250+
availableArea(container, obstacles, position && width ? spanOf(position.x, width) : null),
244251
);
245252
const anchored = position ?? {
246253
x: container.width - PREVIEW_MINI_PLAYER_EDGE_GAP - size.width,

0 commit comments

Comments
 (0)