fix(policies): release the first-show hold when a card scrolls away

A card scrolled beyond the viewport margin while its group read was in flight pauses and aborts the read, but it kept holding the list, so the whole list stayed behind Loading until the user scrolled back. A paused card now releases its hold.
This commit is contained in:
Zakk committed 2026-09-30 00:10:28 +10:00
1 parent 090e1d4d24
commit c48512bb35
2 files changed
+22 -3

No files matched your search

+18
View File
@@ -65,3 +65,21 @@ for (const viewport of [
await expectSteadyCards(page);
});
});
// A card that opened on screen and was scrolled away before its group arrived stops waiting for it, so the list shows.
test('scrolling away from a loading card shows the list', async ({page}) => {
const {api} = await mockBackend(page);
const [first] = await api.groups();
await page.route(new RegExp(`/api/v1/groups/${first.id}(\\?.*)?$`), async route => {
if (route.request().method() === 'GET') await new Promise(resolve => setTimeout(resolve, 15_000));
await route.fallback();
});
await page.setViewportSize({width: 1440, height: 500});
await page.goto('/#/policies');
const list = page.locator('.rp-tabpanel[data-shown] .rp-policy-list');
await expect(list).toHaveAttribute('data-wait', '');
await page.mouse.move(720, 300);
for (let i = 0; i < 10; i++) await page.mouse.wheel(0, 1000);
await expect(page.getByRole('region', {name: first.name, exact: true})).not.toBeInViewport({ratio: 0});
await expect(list).not.toHaveAttribute('data-wait', {timeout: 5_000});
});
+4 -3
View File
@@ -108,15 +108,16 @@ function PolicyDetail(props: PolicyGroupInput) {
const m = usePolicyGroup(props);
const g = m.card;
const gate = use(FirstShow);
const {id} = props;
const {id, paused} = props;
// A card scrolled away stops reading its group, so it no longer holds the list.
useLayoutEffect(() => {
if (!m.loading) {
if (!m.loading || paused) {
gate.release(id);
return;
}
gate.hold(id);
return () => gate.release(id);
}, [gate, id, m.loading]);
}, [gate, id, m.loading, paused]);
return (
<>
<ErrorMessage error={m.error} onRetry={m.retry} />