TanStackT
TanStack13mo ago
11 replies
progressive-amaranth

Is there a way to get proper search params in navigate without a specific route

In my circumstance my /dashboard route has a modal engine that's basically just a discriminated union of different modal types. Using that I am rendering different types of modals


// def
export const modalSchema = z.discriminatedUnion("modalType", [
  deleteEntityModalSchema,
  publishVersionModalSchema,
  uploadImageModalSchema,
  deletePhotoModalSchema,
  buildEntityFromPhotoSchema,
  createFontFamilyModalSchema,
  createFontModalSchema,
  deleteTagModalSchema,
]);

// in dashboard.tsx
  validateSearch: validateWithZod(
    z
      .object({
        modal: modalSchema.optional(),
      })
      .optional()
  )


I need to be able to pop open these modals from a slew of different routes, and I want my code not to care about the specific route, but still be aware of the typesignature coming from "/dashboard", the problem is that when I specify the
from
as dashboard, it affects the route navigation in such a way where I'm not only just either clearing or adding the modal data, I'm also navigating to the /dashboard/ route.


Is there a way to make this work?
Was this page helpful?