From 1e79755121832fe70ea51d3646d79ca3b80cf16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Mon, 27 Jul 2026 16:37:02 +0200 Subject: [PATCH] Derive selection count from live locked rows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bar read the raw selection size for its count, so after a request succeeded and Relay flipped the rows to pending the left count stayed stale while the action count dropped to zero. Resolve the selection against the current rows instead, so requested rows leave the count at once and the bar closes without depending on a clear that may not run. Signed-off-by: Émile Ré --- .../_components/DocumentsSelectionBar.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/compliance-portal/src/pages/documents/_components/DocumentsSelectionBar.tsx b/apps/compliance-portal/src/pages/documents/_components/DocumentsSelectionBar.tsx index 097a0a5df..800d2cc66 100644 --- a/apps/compliance-portal/src/pages/documents/_components/DocumentsSelectionBar.tsx +++ b/apps/compliance-portal/src/pages/documents/_components/DocumentsSelectionBar.tsx @@ -42,17 +42,18 @@ export function DocumentsSelectionBar({ entries }: DocumentsSelectionBarProps) { const { selectedIds, selectAll, clear } = useDocumentSelection(); const { requestAccess, isRequesting } = useBulkRequestAccess(clear); - if (selectedIds.size === 0) { + // Resolve the selection against the live rows so the bar reflects reality even + // if the selection set still holds stale ids: once a request succeeds Relay + // flips those rows to a pending state (locked: false), which must drop them + // from the count immediately rather than waiting on a clear that may not run. + const lockedSelected = entries.filter(entry => entry.locked && selectedIds.has(entry.id)); + const lockedCount = lockedSelected.length; + + if (lockedCount === 0) { return null; } - const lockedSelected = entries.filter(entry => selectedIds.has(entry.id) && entry.locked); - const lockedCount = lockedSelected.length; - const handleRequestAccess = () => { - if (lockedCount === 0) { - return; - } requestAccess(lockedSelected.map(entry => ({ id: entry.id, kind: entry.kind }))); }; @@ -62,7 +63,7 @@ export function DocumentsSelectionBar({ entries }: DocumentsSelectionBarProps) {
- {t("selection.count", { count: selectedIds.size })} + {t("selection.count", { count: lockedCount })}