Skip to content

Commit

Permalink
chore(core): use displayed value for document title (#8268)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin authored Jan 15, 2025
1 parent 4bca7b9 commit 9a5fee3
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ interface UseDocumentTitle {
* @returns The document title or error. See {@link UseDocumentTitle}
*/
export function useDocumentTitle(): UseDocumentTitle {
const {connectionState, schemaType, title, editState} = useDocumentPane()
const documentValue = editState?.draft || editState?.published
const subscribed = Boolean(documentValue)
const {connectionState, schemaType, title, displayed} = useDocumentPane()
const {t} = useTranslation(structureLocaleNamespace)
const subscribed = Boolean(displayed)

const {error, value} = useValuePreview({
enabled: subscribed,
schemaType,
value: documentValue,
value: displayed,
})

if (connectionState === 'connecting' && !subscribed) {
Expand All @@ -42,7 +41,7 @@ export function useDocumentTitle(): UseDocumentTitle {
return {error: undefined, title}
}

if (!documentValue) {
if (!displayed) {
return {
error: undefined,
title: t('panes.document-header-title.new.text', {
Expand Down

0 comments on commit 9a5fee3

Please sign in to comment.