diff --git a/packages/sanity/src/router/RouterProvider.tsx b/packages/sanity/src/router/RouterProvider.tsx index 866c57d650a..2b80bbfcd56 100644 --- a/packages/sanity/src/router/RouterProvider.tsx +++ b/packages/sanity/src/router/RouterProvider.tsx @@ -177,17 +177,6 @@ export function RouterProvider(props: RouterProviderProps): ReactElement { const stickyParamsByName = useMemo(() => Object.fromEntries(stickyParams || []), [stickyParams]) - // Storing perspective state in a dedicated, stable, object allows it to be used for memoization - // separately to the entire router context object, which changes more frequently than the relevant - // sticky parameters. - // - const perspectiveState = useMemo(() => { - return { - perspective: stickyParamsByName.perspective, - excludedPerspectives: stickyParamsByName.excludedPerspectives, - } - }, [stickyParamsByName.excludedPerspectives, stickyParamsByName.perspective]) - const router: RouterContextValue = useMemo( () => ({ navigate, @@ -198,14 +187,12 @@ export function RouterProvider(props: RouterProviderProps): ReactElement { resolvePathFromState, state: routerState, stickyParams: stickyParamsByName, - perspectiveState, }), [ handleNavigateStickyParams, navigate, navigateIntent, onNavigate, - perspectiveState, resolveIntentLink, resolvePathFromState, routerState, diff --git a/packages/sanity/src/router/types.ts b/packages/sanity/src/router/types.ts index c097a14f755..b142f50b921 100644 --- a/packages/sanity/src/router/types.ts +++ b/packages/sanity/src/router/types.ts @@ -293,12 +293,4 @@ export interface RouterContextValue { * The current router state. See {@link RouterState} */ stickyParams: Record - - /** - * Values pertaining to the active perspective. - */ - perspectiveState: { - perspective: string | undefined - excludedPerspectives: string | undefined - } } diff --git a/packages/sanity/src/structure/components/paneItem/PaneItem.tsx b/packages/sanity/src/structure/components/paneItem/PaneItem.tsx index 52e6c262039..6195c896b8b 100644 --- a/packages/sanity/src/structure/components/paneItem/PaneItem.tsx +++ b/packages/sanity/src/structure/components/paneItem/PaneItem.tsx @@ -24,7 +24,6 @@ import { useDocumentPreviewStore, useSchema, } from 'sanity' -import {useRouter} from 'sanity/router' import {MissingSchemaType} from '../MissingSchemaType' import {usePaneRouter} from '../paneRouter' @@ -77,7 +76,6 @@ export function PaneItem(props: PaneItemProps) { const schema = useSchema() const documentPreviewStore = useDocumentPreviewStore() const {ChildLink} = usePaneRouter() - const {perspective} = useRouter().perspectiveState const documentPresence = useDocumentPresence(id) const hasSchemaType = Boolean(schemaType && schemaType.name && schema.get(schemaType.name)) const [clicked, setClicked] = useState(false) @@ -90,7 +88,6 @@ export function PaneItem(props: PaneItemProps) { return ( `. */ export function PaneItemPreview(props: PaneItemPreviewProps) { - const {icon, layout, perspective, presence, schemaType, value} = props + const {icon, layout, presence, schemaType, value} = props const title = (isRecord(value.title) && isValidElement(value.title)) || isString(value.title) || @@ -47,7 +46,7 @@ export function PaneItemPreview(props: PaneItemPreviewProps) { : null const releases = useReleases() - const {bundlesPerspective} = usePerspective() + const {bundlesPerspective, perspective} = usePerspective() const previewStateObservable = useMemo( () => getPreviewStateObservable(props.documentPreviewStore, schemaType, value._id, title, { diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveList.test.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveList.test.tsx index 4682d5b5fb2..ee3e9c2d182 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveList.test.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/__tests__/DocumentPerspectiveList.test.tsx @@ -36,7 +36,6 @@ vi.mock('sanity/router', () => { return { useRouter: vi.fn().mockReturnValue({ stickyParams: {}, - perspectiveState: {}, }), route: { create: vi.fn(), diff --git a/packages/sanity/src/structure/panes/documentList/__tests__/PaneContainer.test.tsx b/packages/sanity/src/structure/panes/documentList/__tests__/PaneContainer.test.tsx index 6c1c1b4d7c4..fb2102d1496 100644 --- a/packages/sanity/src/structure/panes/documentList/__tests__/PaneContainer.test.tsx +++ b/packages/sanity/src/structure/panes/documentList/__tests__/PaneContainer.test.tsx @@ -34,7 +34,6 @@ vi.mock('sanity/router', async (importOriginal) => ({ stickyParams: {}, state: {}, navigate: vi.fn(), - perspectiveState: {}, }), }))