From c3be391e9d1fb6f3b5ad1370b4ff3c2402105671 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Thu, 19 Mar 2026 11:58:06 +0100 Subject: [PATCH] Fix DocumentList: clear selection on filter change, update connection ID, fix indentation Addresses PR review comments: clears selected document IDs when changing the type filter to prevent bulk actions on hidden rows, updates the Relay connection ID when the filter changes so mutations target the correct connection, and fixes eslint indentation violations. Signed-off-by: Bryan Frimin --- .../organizations/documents/DocumentsPage.tsx | 26 +- .../documents/_components/DocumentList.tsx | 281 +++++++++--------- 2 files changed, 161 insertions(+), 146 deletions(-) diff --git a/apps/console/src/pages/organizations/documents/DocumentsPage.tsx b/apps/console/src/pages/organizations/documents/DocumentsPage.tsx index 6ee3ed22a..fdeca3ff6 100644 --- a/apps/console/src/pages/organizations/documents/DocumentsPage.tsx +++ b/apps/console/src/pages/organizations/documents/DocumentsPage.tsx @@ -6,7 +6,7 @@ import { IconPlusLarge, PageHeader, } from "@probo/ui"; -import { useState } from "react"; +import { useMemo, useState } from "react"; import { type PreloadedQuery, usePreloadedQuery, @@ -67,17 +67,21 @@ export default function DocumentsPage(props: { ({ node: { canSendSigningNotifications } }) => canSendSigningNotifications, ); - const [documentListConnectionId, setDocumentListConnectionId] = useState( - ConnectionHandler.getConnectionID( - organizationId, - "DocumentsListQuery_documents", - { - orderBy: { direction: "ASC", field: "TITLE" }, - filter: { documentTypes: null }, - }, - ), + const unfilteredConnectionId = useMemo( + () => + ConnectionHandler.getConnectionID( + organizationId, + "DocumentsListQuery_documents", + { + orderBy: { direction: "ASC", field: "TITLE" }, + filter: { documentTypes: null }, + }, + ), + [organizationId], ); + const [, setDocumentListConnectionId] = useState(unfilteredConnectionId); + const handleSendSigningNotifications = async () => { await sendSigningNotifications({ variables: { @@ -104,7 +108,7 @@ export default function DocumentsPage(props: { )} {organization.canCreateDocument && ( {__("New document")} } diff --git a/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx b/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx index 962fcf2ec..cddab515c 100644 --- a/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx +++ b/apps/console/src/pages/organizations/documents/_components/DocumentList.tsx @@ -86,7 +86,18 @@ export function DocumentList(props: { const handleDocumentTypeFilterChange = (value: string) => { const newType = value === "ALL" ? null : (value as DocumentType); + clear(); setDocumentTypeFilter(newType); + onConnectionIdChange( + ConnectionHandler.getConnectionID( + organizationId, + "DocumentsListQuery_documents", + { + orderBy: { direction: "ASC", field: "TITLE" }, + filter: { documentTypes: newType ? [newType] : null }, + }, + ), + ); startTransition(() => { pagination.refetch( { documentTypes: newType ? [newType] : null }, @@ -165,7 +176,7 @@ export function DocumentList(props: { onValueChange={handleDocumentTypeFilterChange} > - {documentTypes.map((type) => ( + {documentTypes.map(type => ( @@ -174,140 +185,140 @@ export function DocumentList(props: {
{documents.length > 0 - ? ( - ["refetch"]} - > - - {selection.length === 0 - ? ( - - - 0 - } - onChange={() => reset(documents.map(d => d.id))} - /> - - - {__("Name")} - - {__("Status")} - {__("Version")} - - {__("Type")} - - {__("Classification")} - {__("Approvers")} - {__("Last update")} - {__("Signatures")} - {hasAnyAction && } - - ) - : ( - - -
-
- {sprintf(__("%s documents selected"), selection.length)} - {" "} - - - -
-
- {canUpdateAny && ( - - - - )} - {canRequestAnySignatures && ( - - - - )} - - - - {canDeleteAny && ( - - )} -
-
- - - )} - - - {documents.map(document => ( - toggle(document.id)} - key={document.id} - fragmentRef={document} - connectionId={connectionId} - hasAnyAction={hasAnyAction} - /> - ))} - -
- ) - : ( - -
-

- {__("No documents yet")} -

-

- {__("Create your first document to get started.")} -

-
-
- )} + ? ( + ["refetch"]} + > + + {selection.length === 0 + ? ( + + + 0 + } + onChange={() => reset(documents.map(d => d.id))} + /> + + + {__("Name")} + + {__("Status")} + {__("Version")} + + {__("Type")} + + {__("Classification")} + {__("Approvers")} + {__("Last update")} + {__("Signatures")} + {hasAnyAction && } + + ) + : ( + + +
+
+ {sprintf(__("%s documents selected"), selection.length)} + {" "} + - + +
+
+ {canUpdateAny && ( + + + + )} + {canRequestAnySignatures && ( + + + + )} + + + + {canDeleteAny && ( + + )} +
+
+ + + )} + + + {documents.map(document => ( + toggle(document.id)} + key={document.id} + fragmentRef={document} + connectionId={connectionId} + hasAnyAction={hasAnyAction} + /> + ))} + +
+ ) + : ( + +
+

+ {__("No documents yet")} +

+

+ {__("Create your first document to get started.")} +

+
+
+ )}
);