Skip to content

Commit

Permalink
Post Author - don't show 0 in inspector controls (WordPress#51345)
Browse files Browse the repository at this point in the history
When user has no access to authors, authors array was empty and when used as `authorOptions.length`, React would render "0". Changing it to a boolean condition ensures that nothing is rendered instead.
  • Loading branch information
mcliwanow authored and sethrubenstein committed Jul 13, 2023
1 parent 1e59cea commit fdd88a3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/block-library/src/post-author/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ function PostAuthorEdit( {
};

const showCombobox = authorOptions.length >= minimumUsersForCombobox;
const showAuthorControl =
!! postId && ! isDescendentOfQueryLoop && authorOptions.length > 0;

return (
<>
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
{ !! postId &&
! isDescendentOfQueryLoop &&
authorOptions.length &&
{ showAuthorControl &&
( ( showCombobox && (
<ComboboxControl
__nextHasNoMarginBottom
Expand Down

0 comments on commit fdd88a3

Please sign in to comment.