Skip to content

Commit 13bed58

Browse files
tellahoCarl
andcommitted
fix(sidebar): skip unmeasured slides on row membership changes
Keep entry and exit fades when rows are added or removed, but skip retained-row slides until a valid pre-change geometry baseline is available. Preserve prepared recency reorders and their existing motion. Cover removal and re-insertion after hidden Team layout and interface text-size changes in both browser engines. Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@feedback.communities.buzz.xyz> Signed-off-by: Taylor Ho <[email protected]>
1 parent 6c3d410 commit 13bed58

2 files changed

Lines changed: 131 additions & 3 deletions

File tree

‎src/features/channel-navigation/ChannelSidebarRows.tsx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ export function ChannelSidebarRows({
118118
},
119119
[updateOrder],
120120
);
121+
// Membership changes render immediately, before their old slots can be read.
122+
// Preserve presence fades, but do not slide from an unverified baseline.
121123
const rows = sameMembers
122124
? ids.flatMap((id) => {
123125
const child = byId.get(id);
@@ -135,6 +137,7 @@ export function ChannelSidebarRows({
135137
<ChannelRow
136138
key={child.key}
137139
animated={animated}
140+
slide={animated && sameMembers}
138141
index={index}
139142
positions={positions}
140143
hiding={animated && sameMembers && fading.has(String(child.key))}
@@ -154,13 +157,14 @@ const ChannelRow = memo(
154157
{
155158
children: ReactElement;
156159
animated: boolean;
160+
slide: boolean;
157161
index: number;
158162
positions: RowPositions;
159163
hiding: boolean;
160164
onHidden: (id: string) => void;
161165
}
162166
>(function ChannelRow(
163-
{ children, animated, index, positions, hiding, onHidden },
167+
{ children, animated, slide, index, positions, hiding, onHidden },
164168
forwardedRef,
165169
) {
166170
const ref = useRef<HTMLDivElement>(null);
@@ -181,7 +185,7 @@ const ChannelRow = memo(
181185
const previous = positions.get(node);
182186
const top = node.offsetTop;
183187
positions.set(node, { index, top });
184-
if (!present || !animated) {
188+
if (!present || !slide) {
185189
playback.current?.stop();
186190
clearSlide(node);
187191
return;
@@ -216,7 +220,7 @@ const ChannelRow = memo(
216220
delete node.dataset.moving;
217221
node.style.zIndex = "";
218222
});
219-
}, [animated, index, present, positions]);
223+
}, [slide, index, present, positions]);
220224
return (
221225
<motion.div
222226
ref={ref}

‎tests/browser/navigation-sorting.spec.mjs‎

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { test, expect } from "./fixture.mjs";
22
import { open } from "./timeline.mjs";
3+
import { openChannelDetails } from "./channel-details.mjs";
34

45
test.use({ productionBroker: true, savedSidebar: true, sortingSidebar: true });
56

@@ -315,6 +316,129 @@ test.describe("nearby motion after layout changes", () => {
315316
}
316317
});
317318

319+
// Membership updates bypass prepared ordering; real layout and presence fades
320+
// must remain correct after hidden layout or rem-based geometry changes.
321+
test.describe("membership changes after layout changes", () => {
322+
test.use({ initialSidebarSort: { channels: "recent" } });
323+
for (const change of ["Solo to Team", "interface text size"]) {
324+
test(`keeps retained rows still and fades additions/removals after ${change}`, async ({
325+
page,
326+
app,
327+
}) => {
328+
await open(page, app);
329+
const section = page.locator('[data-sidebar-section="channels"]');
330+
const rows = section.locator("button[data-channel-id]:not([inert] *)");
331+
await expect(rows.first()).toHaveAttribute("data-channel-id", "willow");
332+
await openChannelDetails(page);
333+
await page.getByText("Diagnostics", { exact: true }).click();
334+
const refresh = page.getByRole("button", {
335+
name: "Refresh groups and stars",
336+
exact: true,
337+
});
338+
let starred = ["alpha"];
339+
// Model only the host's decoded preferences; its real store drives the rows.
340+
await page.route("**/sidebar-preferences", (route) =>
341+
route.fulfill({
342+
json: {
343+
sections: [{ id: "work", name: "Work", order: 0 }],
344+
assignments: { beta: "work" },
345+
starred,
346+
muted: [],
347+
sort: { channels: "recent" },
348+
},
349+
}),
350+
);
351+
for (const insertion of [false, true]) {
352+
if (change === "Solo to Team") {
353+
const channel = insertion
354+
? await rows.last().getAttribute("data-channel-id")
355+
: "cedar";
356+
await page.getByRole("tab", { name: "Solo", exact: true }).click();
357+
await expect(section).toBeHidden();
358+
app.activity({ channel, kind: 45003, age: insertion ? 29 : 30 });
359+
await expect(rows.first()).toHaveAttribute(
360+
"data-channel-id",
361+
channel,
362+
);
363+
await page.getByRole("tab", { name: "Team", exact: true }).click();
364+
await expect(section).toBeVisible();
365+
} else {
366+
const modifier = await page.evaluate(() =>
367+
/Mac|iPhone|iPad/.test(navigator.platform) ? "Meta" : "Control",
368+
);
369+
for (let step = 0; step < 3; step++)
370+
await page.keyboard.press(`${modifier}+=`);
371+
await expect(page.locator("html")).toHaveCSS(
372+
"--buzz-text-scale",
373+
insertion ? "1.6" : "1.3",
374+
);
375+
}
376+
if (!insertion)
377+
starred.push(await rows.first().getAttribute("data-channel-id"));
378+
const id = starred[1];
379+
const leaving = !insertion
380+
? await rows.first().elementHandle()
381+
: undefined;
382+
const motion = await holdSidebarMotion(page);
383+
try {
384+
if (insertion) starred = ["alpha"];
385+
await refresh.click();
386+
await expect(rows).toHaveCount(insertion ? 3 : 2);
387+
await motion.seek("opacity");
388+
expect(
389+
await rows.evaluateAll(
390+
(elements, id) =>
391+
elements
392+
.filter((element) => element.dataset.channelId !== id)
393+
.every((element) => {
394+
const row = element.closest(
395+
"[data-channel-sidebar-row]",
396+
).parentElement;
397+
return (
398+
!row.hasAttribute("data-moving") &&
399+
row
400+
.getAnimations()
401+
.every(
402+
(animation) =>
403+
!animation.effect
404+
.getKeyframes()
405+
.some((frame) => "transform" in frame),
406+
)
407+
);
408+
}),
409+
id,
410+
),
411+
).toBe(true);
412+
const fading = insertion
413+
? await section
414+
.locator(`button[data-channel-id="${id}"]:not([inert] *)`)
415+
.elementHandle()
416+
: leaving;
417+
const opacity = await fading.evaluate((element) =>
418+
Number(
419+
getComputedStyle(
420+
element.closest("[data-channel-sidebar-row]").parentElement,
421+
).opacity,
422+
),
423+
);
424+
expect(opacity).toBeGreaterThan(0);
425+
expect(opacity).toBeLessThan(1);
426+
if (!insertion)
427+
expect(
428+
await leaving.evaluate((element) => !!element.closest("[inert]")),
429+
).toBe(true);
430+
} finally {
431+
await motion.release();
432+
}
433+
await expect(section.locator("[inert] [data-channel-id]")).toHaveCount(
434+
0,
435+
);
436+
await expect(refresh).toBeEnabled();
437+
}
438+
});
439+
}
440+
});
441+
318442
// Cedar and Willow exchange indices between A–Z and Recent; Maple keeps its
319443
// index. Real browser frames prove the anchor never dims or shifts.
320444
test("keeps a stationary selected row visible while its neighbors exchange places", async ({

0 commit comments

Comments
 (0)