Skip to content

Commit

Permalink
fix: delays rendering the Start in Create banner until document is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
snorrees committed Dec 12, 2024
1 parent 2982082 commit 0f2cf84
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export function StartInCreateBanner(props: StartInCreateBannerProps) {
function StartInCreateBannerInner(props: StartInCreateBannerProps & {appIdCache: AppIdCache}) {
const {studioApp} = useStudioAppIdStore(props.appIdCache)

if (!studioApp) {
// we check documentReady here and not in the top wrapper, to allow the cache code to run while the document is loading
if (!studioApp || !props.documentReady) {
return null
}
return <StartInCreateBannerStudioApp {...props} studioApp={studioApp} />
Expand Down
1 change: 1 addition & 0 deletions packages/sanity/src/core/create/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ export interface StartInCreateBannerProps {
documentType: ObjectSchemaType
document: SanityDocumentLike
isInitialValueLoading: boolean
documentReady: boolean
panelPortalElementId: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export function DocumentLayout() {
schemaType,
value,
isInitialValueLoading,
ready,
} = useDocumentPane()
const {params: paneParams} = usePaneRouter()
const {features} = useStructureTool()
Expand Down Expand Up @@ -259,6 +260,7 @@ export function DocumentLayout() {
document={value}
documentId={documentId}
documentType={schemaType}
documentReady={ready}
isInitialValueLoading={!!isInitialValueLoading}
panelPortalElementId={DOCUMENT_PANEL_PORTAL_ELEMENT}
/>
Expand Down

0 comments on commit 0f2cf84

Please sign in to comment.