fix(dashboard): persist widget drag-drop order (validator was dropping it)
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) <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,12 @@ export const updateUserPreferencesSchema = z.object({
|
|||||||
* update.
|
* update.
|
||||||
*/
|
*/
|
||||||
dashboardWidgets: z.record(z.string(), z.boolean()).optional(),
|
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<typeof updateUserPreferencesSchema>;
|
export type UpdateUserPreferencesInput = z.infer<typeof updateUserPreferencesSchema>;
|
||||||
|
|||||||
Reference in New Issue
Block a user