Skip to content

Commit

Permalink
We can't perform a null ?? check on decodeEntities to verify falsy va…
Browse files Browse the repository at this point in the history
…lues because decodeEntities will return an empty string if it encounters one. (WordPress#51074)

Updated Untitled copy to be consistent with pages view.
  • Loading branch information
ramonjd authored and sethrubenstein committed Jul 13, 2023
1 parent 15a31df commit 62eb41b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ export default function SidebarNavigationScreenPage() {
: null;

if ( _parentTitle?.title ) {
_parentTitle = _parentTitle.title?.rendered
? decodeEntities( _parentTitle.title.rendered )
: __( 'Untitled' );
_parentTitle = decodeEntities(
_parentTitle.title?.rendered || __( '(no title)' )
);
} else {
_parentTitle = __( 'Top level' );
}
Expand Down Expand Up @@ -181,7 +181,9 @@ export default function SidebarNavigationScreenPage() {

return record ? (
<SidebarNavigationScreen
title={ decodeEntities( record?.title?.rendered ) }
title={ decodeEntities(
record?.title?.rendered || __( '(no title)' )
) }
actions={
<SidebarButton
onClick={ () => setCanvasMode( 'edit' ) }
Expand Down Expand Up @@ -218,8 +220,9 @@ export default function SidebarNavigationScreenPage() {
altText
? decodeEntities( altText )
: decodeEntities(
record.title?.rendered
) || __( 'Featured image' )
record.title?.rendered ||
__( 'Featured image' )
)
}
src={ mediaSourceUrl }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ export default function SidebarNavigationScreenPages() {
>
<Truncate numberOfLines={ 1 }>
{ decodeEntities(
homeTemplate.title?.rendered
) ?? __( '(no title)' ) }
homeTemplate.title?.rendered ||
__( '(no title)' )
) }
</Truncate>
</PageItem>
) }
Expand All @@ -137,8 +138,9 @@ export default function SidebarNavigationScreenPages() {
>
<Truncate numberOfLines={ 1 }>
{ decodeEntities(
item.title?.rendered
) ?? __( '(no title)' ) }
item?.title?.rendered ||
__( '(no title)' )
) }
</Truncate>
</PageItem>
);
Expand All @@ -154,8 +156,9 @@ export default function SidebarNavigationScreenPages() {
>
<Truncate numberOfLines={ 1 }>
{ decodeEntities(
item.title?.rendered
) ?? __( '(no title)' ) }
item.title?.rendered ||
__( '(no title)' )
) }
</Truncate>
</PageItem>
) ) }
Expand Down

0 comments on commit 62eb41b

Please sign in to comment.