From ee4d5c861023b247196c886631802fc06a79abf3 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 22 May 2026 14:26:39 +0200 Subject: [PATCH] fix(dashboard): persist widget drag-drop order (validator was dropping it) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit N46 (a147cbc) shipped the drag-drop UI + optimistic mutation, but the PATCH body was being silently stripped by the user-preferences Zod validator — `dashboardWidgetOrder` wasn't in the schema, so Zod's default strip-unknown-keys behaviour dropped it before the DB write. Symptom: drop the widget in a new position → UI reflects the order optimistically → onSettled invalidates + refetches → GET returns the unchanged-on-disk order → dashboard snaps back to the original layout. Added the field to updateUserPreferencesSchema with the same loose shape (array-of-string) the schema declared 100+ lines earlier. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/lib/validators/user-preferences.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/validators/user-preferences.ts b/src/lib/validators/user-preferences.ts index ddbcebcb..ed4c1dd9 100644 --- a/src/lib/validators/user-preferences.ts +++ b/src/lib/validators/user-preferences.ts @@ -21,6 +21,12 @@ export const updateUserPreferencesSchema = z.object({ * update. */ dashboardWidgets: z.record(z.string(), z.boolean()).optional(), + /** + * Rep-chosen dashboard widget order (drag-drop). Missing ids fall + * through to registry order so newly-added widgets always surface. + * Kept loose (array-of-string) for the same reason as above. + */ + dashboardWidgetOrder: z.array(z.string()).optional(), }); export type UpdateUserPreferencesInput = z.infer;