diff --git a/src/common/view.ts b/src/common/view.ts index c0410cfd..bf2b5efd 100644 --- a/src/common/view.ts +++ b/src/common/view.ts @@ -19,7 +19,7 @@ export const savedViewSchema = z.object({ "Title may only contain alphanumeric characters, spaces, and dashes, and cannot begin or end with a space or dash.", ) .optional(), - order: z.number().optional(), + order: z.number().safe().optional(), viewState: z.object({}).passthrough(), // TODO: extract view options from web/ so we can have type safety here }); diff --git a/src/web/view/quickViewStore/store.ts b/src/web/view/quickViewStore/store.ts index 355d1076..59a6e8db 100644 --- a/src/web/view/quickViewStore/store.ts +++ b/src/web/view/quickViewStore/store.ts @@ -129,7 +129,8 @@ export const createView = () => { id: newViewId, type: "quick", title: newTitle, - order: Math.max(...state.views.map((view) => view.order)) + 1, + // provide -1 by default to `Math.max` because otherwise it returns -Infinity with no arguments + order: Math.max(-1, ...state.views.map((view) => view.order)) + 1, viewState: currentView, };