diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveMenu.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveMenu.tsx index 256a77953486..9dd488950a8b 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveMenu.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/perspective/DocumentPerspectiveMenu.tsx @@ -3,6 +3,7 @@ import {Text} from '@sanity/ui' import {memo, useCallback} from 'react' import { getVersionFromId, + isVersionId, useBundles, useDateTimeFormat, usePerspective, @@ -25,7 +26,7 @@ export const DocumentPerspectiveMenu = memo(function DocumentPerspectiveMenu() { }) const {data: bundles, loading} = useBundles() - const {documentVersions, editState, displayed, documentType} = useDocumentPane() + const {documentVersions, editState, displayed, documentType, version} = useDocumentPane() // remove the versions that the document already has // remove the archived releases @@ -59,20 +60,26 @@ export const DocumentPerspectiveMenu = memo(function DocumentPerspectiveMenu() { } disabled={!editState?.published} onClick={handleBundleChange('published')} - selected={editState?.published?._id === displayed?._id} + selected={ + editState?.published?._id === displayed?._id && + Boolean(editState?.published) && + Boolean(editState?.draft) + } // eslint-disable-next-line @sanity/i18n/no-attribute-string-literals text="Published" icon={DotIcon} tone="positive" menuContent={ - + editState?.published ? ( + + ) : null } /> } - disabled={!editState?.published && !editState?.draft} icon={DotIcon} - selected={editState?.draft?._id === displayed?._id} + selected={ + (editState?.draft?._id === displayed?._id || + !editState?.draft || + !editState?.published) && + !isVersionId(displayed?._id || '') + } // eslint-disable-next-line @sanity/i18n/no-attribute-string-literals text="Draft" tone="caution" onClick={handleBundleChange('drafts')} menuContent={