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

Child blocks are displayed in the block inserter and block visibility doesn't work #65687

Closed
t-hamano opened this issue Sep 27, 2024 · 14 comments · Fixed by #65700 or #67734
Closed

Child blocks are displayed in the block inserter and block visibility doesn't work #65687

t-hamano opened this issue Sep 27, 2024 · 14 comments · Fixed by #65700 or #67734
Assignees
Labels
[Feature] Inserter The main way to insert blocks using the + button in the editing interface [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@t-hamano
Copy link
Contributor

t-hamano commented Sep 27, 2024

What problem does this address?

I found two issues in the trunk:

  • Child blocks that have a specific parent, such as the List Item, are displayed. When you click on the block, it will say "Block "{blockName}" can't be inserted.". (This may be a new specification)
  • "Manage block visibility" doesn't work.

I used git bisect and it looks like this issue occurred in #65490.

957141419a3cef7be97099ce0c69e8f8.mp4

cc @youknowriad @andrewserong @jorgefilipecosta

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Feature] Inserter The main way to insert blocks using the + button in the editing interface labels Sep 27, 2024
@youknowriad
Copy link
Contributor

Thanks for catching the bug and creating the issue. It seems the new behavior to "compute insertion point" on the fly should only apply to specific conditions, not all the conditions of when a block is visible or not.

So it's like we need two different kind of selectors:

  • Can insert block
  • Is block visible

I'll explore something.

@youknowriad
Copy link
Contributor

We should have e2e tests about the "manage block visibility" thing

@Mamaduka
Copy link
Member

Mamaduka commented Nov 5, 2024

I think the #65700 only partially resolved the issue.

Child blocks that have a specific parent, such as the List Item, are displayed. When you click on the block, it will say "Block "{blockName}" can't be inserted.". (This may be a new specification)

This one remains. All child blocks are visible for the default root. The child blocks are no longer displayed when I select any container block, which causes a somewhat expensive re-render.

Screencast

CleanShot.2024-11-05.at.17.35.01.mp4

@t-hamano
Copy link
Contributor Author

t-hamano commented Nov 6, 2024

All child blocks are visible for the default root. The child blocks are no longer displayed when I select any container block, which causes a somewhat expensive re-render.

This is indeed a strange behavior. However, I remember that there was an effort to show all blocks in #62169. Should all blocks, including children, be shown in a container block?

@Mamaduka
Copy link
Member

Mamaduka commented Nov 6, 2024

After #62169, you see all blocks in the inserter. When container sets allow children, they're displayed at the top, followed by the remaining blocks. Click on rest (non-allowed in the container) blocks; insert those after the container.

I think the current behavior for the default root ID ( ' ' ) is a bug.

@ellatrix, @youknowriad, what do you think?

@youknowriad
Copy link
Contributor

I agree, that ideally child blocks should only appear if you're within the parent (not necessarily directly, but at least it's an ancestor to the current selection)

@Mamaduka
Copy link
Member

Should I re-open this issue or create a new one?

@youknowriad
Copy link
Contributor

Let's reopen it.

@youknowriad youknowriad reopened this Nov 13, 2024
@youknowriad youknowriad removed their assignment Nov 13, 2024
@annezazu
Copy link
Contributor

Noting that I just got reports of the same problem (I think) reported here with the buttons & button blocks:

bug.in.buttons.mov

For 6.6, we only show "buttons" I imagine to preserve the parent/child relationship and provide a better UX for styling:

Image

@Mamaduka
Copy link
Member

I just noticed that the behavior of the inserter items is broken for every rootClientId that doesn't limit blocks.

I'll prioritize working on a fix for this bug.

@talldan
Copy link
Contributor

talldan commented Dec 9, 2024

This bug caused confusion in the latest WordPress speed build 😬

@jeryj
Copy link
Contributor

jeryj commented Dec 11, 2024

Instead of hiding blocks that can't be inserted at that level, what if we leave the block visible and add the necessary wrapping blocks to insert it?

So, if someone selects Column from the inserter and there's no wrapping Columns block, add a Columns block with a Column block within it.

@youknowriad
Copy link
Contributor

Instead of hiding blocks that can't be inserted at that level, what if we leave the block visible and add the necessary wrapping blocks to insert it?

That's a decent idea but IMO, we don't know enough to make the right call. While it can work for "column" and "block". I don't see anyone inserting "query pagination" and having a "query" around it or something like that.

@jeryj
Copy link
Contributor

jeryj commented Dec 11, 2024

Good point. But for other blocks it could be really helpful, like "Instagram" could add the social icons wrapping block for it. Otherwise you have to know to search for "social icons" first.

That said, this may guide you to even less of an understanding of how it works. You may end up with a different social icons block for each icon 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Inserter The main way to insert blocks using the + button in the editing interface [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
6 participants