You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Navigation block: Unable to use sub-menu item & deletion deletes parent menu #36977
When using the Navigation block and added sub-menu items, I noticed that there appears to be a regression in behavior where I'm unable to see the sub-menu item upon addition and, if I remove it, it also removes the parent menu item.
Step-by-step reproduction instructions
Add a navigation block.
Add a few menu items.
Add a sub menu item.
See initial state where you can't seem to add in a link to the sub menu container.
Try to delete the sub menu item and notice it deletes the parent.
Screenshots, screen recording, code snippet
sub.menu.item.mov
Environment info
WordPress 5.9-alpha-52262
Gutenberg 12.01
TT1 blocks
Chrome
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 indeed. This appears to be a side effect of showing the block toolbar below the block if the block is near the top of the screen, as ticketed in #29464. The behavior, I feel, still makes sense to have for blocks that truly bump against the edge; for example some of the TT2 patterns go all the way to the top for the header template parts.
CC: @Addison-Stavlo: do you recall if there are some levers we can adjust to this behavior? Also CC: @jameskoster, because an alternative fix might be to introduce the dark gray frame after all. I don't necessarily love doing this as it reduces the available real estate, but in weighing trade offs, it might be an option.
Another solution which might actually be better than the above is to change back the block toolbar absorbtion. Right now the block toolbar of submenu items is absorbed in the top toolbar, as opposed to being positioned near the block. This is ticketed separately as being a bit confusing due to the lack of spatial context. But in this case it might also mitigate the issue, as there would most likely be clearance enough above the selected first submenu block to accommodate the toolbar without bumping it below. CC: @getdave in case you have thoughts.
Other than that it's a UX concern. When we introduced the capture toolbars the UX with the toolbar locked to the nested submenu was very poor. If that's improved then we might benefit from removing the capturing behaviour on this block. I'll leave that decision to design folks though 🙇
Oh thank you, both for the fast response and the code piece.
It was definitely needed, back in the day! Every block had borders around them, and there was a great deal of UI weight to deal with. I do think we've definitely reached a point where the UI can handle it. The one thought I still have attached to this is that we might still want the submenu block to capture the toolbars, instead of the navigation block, the idea being that as you build out the submenu, it can be helpful to see the preceding menu.
Seeing as it's only applied when horizontal, I took the vertical version for a spin:
I think it's okay, and that if it helps mitigate this issue, it might be worth it.
@Addison-Stavlo: do you recall if there are some levers we can adjust to this behavior?
I do not, unfortunately. There could be someway to go about that with more digging, but nothing I remember at a glance.
we might still want the submenu block to capture the toolbars, instead of the navigation block
I think this makes a lot of sense. If the toolbar is not positioned with respect to the selected block (the submenu in this case), then I think it becomes increasingly difficult for the toolbar to behave in a manner that is non-intrusive in all cases.
It isn't just an issue in the nav block, we should also consider that positioning the toolbar under the block might be a problem for third-party blocks too. Any block that overflows its container like the nav block does will have this issue.
positioning the toolbar under the block might be a problem for third-party blocks too. Any block that overflows its container like the nav block does will have this issue.
Technically couldn't a 3rd party block could also overflow its container from above? In that case positioning it above the block would have the same issue.
This does seem difficult to handle well. Right now, bottom positioning should only happen if there isn't enough room for top positioning to happen without the toolbar obstructing the selected block. With the previous always-top positioning, there were instances where the toolbar would cover the navigation block itself when selected (and other blocks as well) which is why we tried moving it beneath the selected block when this would be the case. The bottom positioned toolbar can obstruct blocks that overflow their boundaries, but that seems less of an issue than the toolbar obstructing inside the well defined boundaries of the selected block itself (but still something we need to figure out how to handle). 🤔
Another idea might be that when the toolbar would obstruct the given block boundaries, instead of moving the toolbar below the block we move it into the fixed top-toolbar location. However, this would be a lot more 'jumpy' in editor interaction that I assume would not feel very favorable to folks either.
Outside of completely disabling the "show toolbar below block" feature, is it possible to add an edgebuffer so it only activates when the block is most literally touching the top edge? For example for header template parts?
Technically couldn't a 3rd party block could also overflow its container from above? In that case positioning it above the block would have the same issue.
I don't think many would do that because the toolbar has always been above the block.
Activity
annezazu commentedon Nov 29, 2021
Previous sub menu item behavior:
https://user-images.githubusercontent.com/26996883/143949011-f22b5994-efd4-48b4-a27e-1c69abc65637.mov
Marking this as a regression for now!
jasmussen commentedon Nov 30, 2021
Yes indeed. This appears to be a side effect of showing the block toolbar below the block if the block is near the top of the screen, as ticketed in #29464. The behavior, I feel, still makes sense to have for blocks that truly bump against the edge; for example some of the TT2 patterns go all the way to the top for the header template parts.
CC: @Addison-Stavlo: do you recall if there are some levers we can adjust to this behavior? Also CC: @jameskoster, because an alternative fix might be to introduce the dark gray frame after all. I don't necessarily love doing this as it reduces the available real estate, but in weighing trade offs, it might be an option.
jasmussen commentedon Nov 30, 2021
Another solution which might actually be better than the above is to change back the block toolbar absorbtion. Right now the block toolbar of submenu items is absorbed in the top toolbar, as opposed to being positioned near the block. This is ticketed separately as being a bit confusing due to the lack of spatial context. But in this case it might also mitigate the issue, as there would most likely be clearance enough above the selected first submenu block to accommodate the toolbar without bumping it below. CC: @getdave in case you have thoughts.
getdave commentedon Nov 30, 2021
As far as I remember it's a one liner fix. Simply remove this line
gutenberg/packages/block-library/src/navigation/edit/inner-blocks.js
Line 117 in 570751a
Other than that it's a UX concern. When we introduced the capture toolbars the UX with the toolbar locked to the nested submenu was very poor. If that's improved then we might benefit from removing the capturing behaviour on this block. I'll leave that decision to design folks though 🙇
jasmussen commentedon Nov 30, 2021
Oh thank you, both for the fast response and the code piece.
It was definitely needed, back in the day! Every block had borders around them, and there was a great deal of UI weight to deal with. I do think we've definitely reached a point where the UI can handle it. The one thought I still have attached to this is that we might still want the submenu block to capture the toolbars, instead of the navigation block, the idea being that as you build out the submenu, it can be helpful to see the preceding menu.
Seeing as it's only applied when horizontal, I took the vertical version for a spin:

I think it's okay, and that if it helps mitigate this issue, it might be worth it.
jameskoster commentedon Nov 30, 2021
FWIW, adding the frame in the Site Editor is also a consideration for https://github.com/WordPress/gutenberg/issues/36535.
Addison-Stavlo commentedon Nov 30, 2021
I do not, unfortunately. There could be someway to go about that with more digging, but nothing I remember at a glance.
I think this makes a lot of sense. If the toolbar is not positioned with respect to the selected block (the submenu in this case), then I think it becomes increasingly difficult for the toolbar to behave in a manner that is non-intrusive in all cases.
talldan commentedon Dec 1, 2021
I also made an issue about this - https://github.com/WordPress/gutenberg/issues/36335
It isn't just an issue in the nav block, we should also consider that positioning the toolbar under the block might be a problem for third-party blocks too. Any block that overflows its container like the nav block does will have this issue.
Addison-Stavlo commentedon Dec 1, 2021
Technically couldn't a 3rd party block could also overflow its container from above? In that case positioning it above the block would have the same issue.
This does seem difficult to handle well. Right now, bottom positioning should only happen if there isn't enough room for top positioning to happen without the toolbar obstructing the selected block. With the previous always-top positioning, there were instances where the toolbar would cover the navigation block itself when selected (and other blocks as well) which is why we tried moving it beneath the selected block when this would be the case. The bottom positioned toolbar can obstruct blocks that overflow their boundaries, but that seems less of an issue than the toolbar obstructing inside the well defined boundaries of the selected block itself (but still something we need to figure out how to handle). 🤔
Another idea might be that when the toolbar would obstruct the given block boundaries, instead of moving the toolbar below the block we move it into the fixed top-toolbar location. However, this would be a lot more 'jumpy' in editor interaction that I assume would not feel very favorable to folks either.
noisysocks commentedon Dec 1, 2021
This is a duplicate of https://github.com/WordPress/gutenberg/issues/36335 but since this issue has more discussion I'll close https://github.com/WordPress/gutenberg/issues/36335.
jasmussen commentedon Dec 8, 2021
Outside of completely disabling the "show toolbar below block" feature, is it possible to add an edgebuffer so it only activates when the block is most literally touching the top edge? For example for header template parts?
talldan commentedon Dec 8, 2021
I don't think many would do that because the toolbar has always been above the block.
23 remaining items