From 038fc72be2d0179b59ae29081611a948c944d56f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 10 Sep 2026 01:57:42 +0200 Subject: [PATCH] fix(settings): keep a managed record's edit form across a refetch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fields component was keyed on the query's `dataUpdatedAt` under a comment saying the key stopped a refetch landing mid-edit from replacing what somebody is typing. It did the reverse: the timestamp moves every time the query resolves, so invalidating the `managed-profiles` prefix from anywhere — the guardian list on another row is enough — remounted the fields and threw the half-typed name away. Keyed on the record's id instead, which is stable for as long as the form is about the same record. --- .../settings/access/managed-profile-edit-form.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/settings/access/managed-profile-edit-form.tsx b/src/components/settings/access/managed-profile-edit-form.tsx index a293f730e..44a0f4ba7 100644 --- a/src/components/settings/access/managed-profile-edit-form.tsx +++ b/src/components/settings/access/managed-profile-edit-form.tsx @@ -99,12 +99,17 @@ export function ManagedProfileEditForm({ ); } - // Keyed on the loaded record so the field state below is seeded from it once - // rather than through an effect that re-seeds on every refetch — a refetch - // landing mid-edit must not silently replace what somebody is typing. + // Keyed on WHICH record is open, so the field state below is seeded once per + // record rather than through an effect that re-seeds on every refetch. The + // key was the query's `dataUpdatedAt`, which did the opposite of what it + // claimed: any invalidation of the `managed-profiles` prefix — removing a + // guardian from another row, say — refetches this read, moves the timestamp + // and remounts the fields, so a half-typed name disappears while somebody is + // looking at it. The id is stable for as long as the form is about the same + // record, which is exactly as long as the seeding should hold. return (