Post Author - don't show 0 in inspector controls #51345
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
This is a small fix addressing "0" displayed when user has no rights for fetching post authors.
Fixes: #51342
Why?
Even though
0
is a falsy value and it seems fine for using when rendering components conditionally, React will render it as0
(when value isfalse
, React renders nothing).How?
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.Another approach could be using a ternary operator and returning
null
if the condition is falsy.Testing Instructions
Screenshots or screencast
Before:
After: