Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post Author - don't show 0 in inspector controls #51345

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Post Author - don't show 0 in inspector controls
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.
mcliwanow committed Jun 8, 2023
commit 2933f4fcac5ae0fa69aede1202078899197da76c
6 changes: 3 additions & 3 deletions packages/block-library/src/post-author/edit.js
Original file line number Diff line number Diff line change
@@ -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