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 Block doesn't display when author has no posts #40431

Closed
annezazu opened this issue Apr 18, 2022 · 5 comments · Fixed by #40648
Closed

Post Author Block doesn't display when author has no posts #40431

annezazu opened this issue Apr 18, 2022 · 5 comments · Fixed by #40648
Assignees
Labels
[Block] Post Author Affects the Post Author Block [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Type] Bug An existing feature does not function as intended

Comments

@annezazu
Copy link
Contributor

Description

If you add a Post Author block to the Author template and view the template for an author without any posts yet, the post author block doesn't display. This was found as part of the thirteenth call for testing for the FSE Outreach Program:

But if there are no posts for the author, the Author tag disappears (displays nothing) on the author archive page. However, the author name still shows in the page title (in the tab in Chrome browser). It seems odd to me that if there are no posts, the page title still knows the author name, but the Post Author block just does not display anything.

Step-by-step reproduction instructions

  1. Open Site Editor.
  2. Navigate to the Templates List.
  3. Click "Add" and add in an author template.
  4. Add a Post Author block at the top of the template.
  5. Add a Query Loop below it with the option of “Inherit query from template” selected.
  6. Publish the template.
  7. View an author with posts and see the author name.
  8. View an author without posts and notice that the author name does not display.

Screenshots, screen recording, code snippet

Here's a quick video of me demonstrating the problem:
https://user-images.githubusercontent.com/26996883/163894155-98f43d27-0442-45b8-96a7-6fb305ca66b0.mov

Environment info

  • WordPress 6.0 beta 1.
  • No GB.
  • TT2

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@annezazu annezazu added [Type] Bug An existing feature does not function as intended [Block] Post Author Affects the Post Author Block [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") labels Apr 18, 2022
@mauriac
Copy link
Member

mauriac commented Apr 20, 2022

TEST REPORT

  • Go to WordPress customize page, ensure that the option "Your latest posts" in homepage settings is set.

wp_settings_home_page

  • Open Site Editor.
  • Add a Post Author block
  • In the block's setting, change the author from the current to any other author.
  • notice that in the editor the author's name didn't change accordingly

After some debug it appears that the bug is due to the missing of postType and postId.

introduced here: #19894 (looks like an oversight)


ping @draganescu since he spearheaded this part of code and I am not sure what should be the best way to fix this. Should we disable the block when there's no postId?

I'm open to any suggestion, and then I can ship a patch.

@draganescu
Copy link
Contributor

@mauriac the problem you reported seems different from the one in the issue. Changing the author outside of a post has no effect since there is no post to edit. I think that drop-down should not show if there is not post.

@draganescu
Copy link
Contributor

Trying to see if it's trivial to bring over the feature the query block has to get post from query.

@draganescu
Copy link
Contributor

So the problem here is that when there are no posts, the author block does not get any post id from the context. This is a quirk of how block context works on the server-side, for some reason if there are posts, the contextual post type and post id are set to the 1st one in the list of posts from the query block.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Apr 27, 2022
@mauriac
Copy link
Member

mauriac commented May 1, 2022

@mauriac the problem you reported seems different from the one in the issue. Changing the author outside of a post has no effect since there is no post to edit. I think that drop-down should not show if there is not post.

I used to think that fix the postId missing will fix this issue, this is due to my first understand of the block purpose; but now I guess you are right. I'll create a new issue related to my problem and I'll probably ship a patch according to your comment ========> I think that drop-down should not show if there is not post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Author Affects the Post Author Block [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants