From ffe53d3fb52d06984d3f6ffbd02678bb7cdcebb0 Mon Sep 17 00:00:00 2001 From: dswbx Date: Tue, 23 Sep 2025 13:47:10 +0200 Subject: [PATCH] fix: ensure form updates with latest data after mutation added a form reset to reflect up-to-date data changes and adjusted mutation to prevent id exclusion, ensuring lists are updated properly. --- app/src/ui/client/api/use-entity.ts | 1 + app/src/ui/routes/data/data.$entity.$id.tsx | 3 +++ 2 files changed, 4 insertions(+) diff --git a/app/src/ui/client/api/use-entity.ts b/app/src/ui/client/api/use-entity.ts index 907bc33..b77b57d 100644 --- a/app/src/ui/client/api/use-entity.ts +++ b/app/src/ui/client/api/use-entity.ts @@ -156,6 +156,7 @@ export const useEntityQuery = < // mutate all keys of entity by default if (options?.revalidateOnMutate !== false) { + // don't use the id, to also update lists await mutateFn(); } return res; diff --git a/app/src/ui/routes/data/data.$entity.$id.tsx b/app/src/ui/routes/data/data.$entity.$id.tsx index 0b91fa5..a21d444 100644 --- a/app/src/ui/routes/data/data.$entity.$id.tsx +++ b/app/src/ui/routes/data/data.$entity.$id.tsx @@ -77,6 +77,9 @@ function DataEntityUpdateImpl({ params }) { message: `Successfully updated ID ${entityId}`, color: "green", }); + + // make sure form picks up the latest data + Form.reset(); } catch (e) { setError(e instanceof Error ? e.message : "Failed to update"); }