@@ -20,7 +20,7 @@ interface PostTitleEditProps {
2020 include ?: string ;
2121 orderby ?: string ;
2222 } ;
23- pinnedPosts ?: Array < number > ;
23+ pinnedPosts ?: Array < number | null > ;
2424 customPostTitles ?: {
2525 postId : number ;
2626 title : string ;
@@ -46,13 +46,13 @@ export default function Edit({
4646 const queryParentId = queryParentIds . length ? queryParentIds [ queryParentIds . length - 1 ] : null ;
4747
4848 const {
49- postId,
49+ postId = null ,
5050 pinnedPosts = [ ] ,
51- query : { postType = 'post' } ,
51+ query : { postType = 'post' } = { } ,
5252 customPostTitles = [ ] ,
5353 } = context ;
5454 const { level = 3 , supportsLevel } = attributes ;
55- const [ rawTitle = '' , , fullTitle ] = useEntityProp ( 'postType' , postType , 'title' , postId . toString ( ) ) ;
55+ const [ rawTitle = '' , , fullTitle ] = useEntityProp ( 'postType' , postType , 'title' , postId ? .toString ( ) ) ;
5656 const isPinned = pinnedPosts . includes ( postId ) ;
5757 const currentCustomPostTitle = customPostTitles . find ( ( item ) => item ?. postId === postId ) ;
5858 const TagName = ! supportsLevel || level === 0 ? 'p' : `h${ level } ` ;
@@ -74,6 +74,10 @@ export default function Edit({
7474 } , [ isPinned , postId , customPostTitles , currentCustomPostTitle , setAttributes , queryParentId ] ) ;
7575
7676 const handleOnChange = ( title : string ) => {
77+ if ( ! postId ) {
78+ return ;
79+ }
80+
7781 /**
7882 * Handle case for removing custom title from the collection if a
7983 * custom title no longer exists.
0 commit comments