WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.52k stars 4.2k forks source link

Missing inspector UI in post template block #58469

Open draganescu opened 9 months ago

draganescu commented 9 months ago

Description

If you have a title in a post content block in a query loop, but the query has no results, and you select the post title in the list view, the inspector does not show any of the block’s controls, not does the block toolbar.

Step-by-step reproduction instructions

Screenshots, screen recording, code snippet

https://github.com/WordPress/gutenberg/assets/107534/bf87e084-cd48-4a74-b87e-0145b3329c86

Environment info

No response

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

t-hamano commented 9 months ago

I was also able to reproduce this problem. Perhaps all the blocks inside the Post Template block will not have inspector UI displayed if there is no result of the loop. However, only block variations and block styles seem to be displayed.

image image

t-hamano commented 9 months ago

My guess is that the underlying problem is that the block itself is not rendered to the canvas if there are no query results. Each block should have inserted its content into a slot via an InspectorControl within the Edit component or a BlockEdit hook. If the block itself, the Edit component, is not rendered, then the InspectorControl itself is not rendered either.

draganescu commented 9 months ago

Yeah I am not sure how to approach this best, I don't think it's a bug, but more a UI quick we need to account for.

luminuu commented 2 months ago

This behaviour also appears when you have no published posts in your install. Create a fresh install and remove the "Hello world!" post. If you then try to edit a query loop, this happens.

But shouldn't it be possible anyway to work with the blocks there to use as placeholders, even if no content is present?