Gutenberg: Nested blocks should limit the depth of nesting within them

Created on 3 Apr 2018  路  3Comments  路  Source: WordPress/gutenberg

Issue Overview

Currently, it's possible to add a Columns (Experimental) block within a Columns (Experimental) block many times over, and this makes for some weird inception-like behaviour.

Steps to Reproduce (for bugs)


  1. Add a Columns (Experimental) block.
  2. Within the first column, add another Columns (Experimental) block.
  3. Rinse, repeat.

Expected Behavior

  • Nested blocks should not allow other nested blocks to be inserted within them, except in specifically determined situations.
  • Nested blocks should limit the depth of nesting.

Current Behavior

There are no restrictions in recursive nesting.

Possible Solution

  • Nested blocks should not allow other nested blocks to be inserted within them, except in specifically determined situations.
  • Nested blocks should limit the depth of nesting.

Screenshots / Video

Columns

Related Issues and/or PRs

Possibly related to #5448.

Todos

  • [ ] Tests
  • [ ] Documentation
[Feature] Nested / Inner Blocks [Type] Enhancement

Most helpful comment

My ticket was badly named. I think the point I was trying to make was that the experience of nesting more than one level deep is not very user-friendly at present.

All 3 comments

It should be noted that there are cases where several levels of nesting would be very useful, such as a layout like the following:

  • section

    • columns (comprised of 2 columns: 1/4 + 3/4)

    • heading (in column 1)

    • columns (in column 1 - comprised of 2 columns: 1/2 + 1/2)



      • button


      • button



    • paragraph (in column 2)

    • paragraph

I have seen columns nested in columns multiple times, and if the proposed section block gets added, there will definitely be situations where columns containing nested columns are in turn nested into those.

One of the things that has to be considered is how a restriction on nesting depth would be implemented. A global hard limit would probably be a bad idea, in my opinion. As for the parent determining which blocks can be inserted into it and vice-versa (see #5448), that sounds like a good idea. But if columns are going to only restrict nesting depending on how many levels of nesting there already are, then the check for what blocks are allowed as children of a parent block (or vice-versa) becomes considerably more complicated, since you have to check not only direct parents or children, but also the parents of the parents or children of the children, and also accounting for other blocks in between the blocks (e.g. columns -> section -> columns) as well.

It should also be noted that #5658 has been merged, so the UI for navigating through and adding blocks to levels of nested blocks should be a lot easier now; perhaps a nesting limit may not even be necessary?

My ticket was badly named. I think the point I was trying to make was that the experience of nesting more than one level deep is not very user-friendly at present.

Closing in favor of #6593 which is similar and more recent / relevant.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maddisondesigns picture maddisondesigns  路  3Comments

moorscode picture moorscode  路  3Comments

aaronjorbin picture aaronjorbin  路  3Comments

youknowriad picture youknowriad  路  3Comments

mhenrylucero picture mhenrylucero  路  3Comments