Problem/Motivation
The "Block description" "field" renders at the top of the modal form within the content area. In my experience it displays the block type of the block being created/edited. My issue with this is that it's not really a field because it isn't something the user can edit. In reality it's only there to give the user context.
Proposed resolution
I think it would be much more appropriate for it to appear as part of the modal title. This would save room in the content area and avoid user confusion.

I've done some digging and found that the current title "Configure block" comes directly from web/core/modules/layout_builder/layout_builder.routing.yml.
I realize that this request may be beyond the scope of this module because it touches on core Layout Builder and Block configuration form issues. However, I don't think these user interface issues with block configuration will ever be addressed in core. There's just too many other more pressing issues. The way I see it, the purpose of this module is already to improve the usability of Layout Builder by replacing core functionality, so maybe it could improve the actual block configuration form as well? Maybe there's a chance to replace the title before the jQuery UI Dialog is initialized?
Thanks for considering and thanks for this module. Layout Builder would be unusable without it. I'll do some more digging into this.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | block-title-in-modal-title-3196147-9.patch | 5.91 KB | maskedjellybean |
| #8 | interdiff_2-8.txt | 697 bytes | lasseitorp |
| #8 | block-title-in-modal-title-3196147-8.patch | 5.75 KB | lasseitorp |
| #2 | block-title-in-modal-title-3196147-2.patch | 5.72 KB | maskedjellybean |
| #2 | Screen Shot 2021-02-03 at 11.29.59 AM.png | 63 KB | maskedjellybean |
Issue fork layout_builder_modal-3196147
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
maskedjellybeanHere's a patch for this.
The reason I created
_layout_builder_modal_dialog_options()was because the code to set the dialog options was duplicated inlayout_builder_modal_link_alter()and inlayout_builder_modal_contextual_links_alter(). I figured it makes sense to move it all to a function to avoid duplication.I hope I'm correct in assuming that if $plugin_base_id is "inline_block" we can assume the entity_type is block_content.
The code to determine the title is more opinionated than I would've liked. The label for views_bock blocks are apparently not set in the Layout Builder SectionComponent configuration, so I had to dig into the view to construct the title.
Steps to test:
Comment #5
lasseitorp commentedI ran into the issue
Notice: Undefined index: uuid in /web/modules/contrib/layout_builder_modal/layout_builder_modal.module on line 107as the UUID in the $route_parameters isn't always set, so I added a guard on line 107.Comment #6
lasseitorp commentedComment #7
edurenye commented@lasseitorp When you publish a new patch, if is not a rebase, always publish an interdiff, makes it easy to review the changes. Could you please provide the interdiff file?
Thank you!
Comment #8
lasseitorp commented@edurenye Sorry here is a new patch with a interdiff.
Comment #9
maskedjellybeanI'm sorry for uploading another patch without an interdiff. I really did try to generate one using https://github.com/mglaman/drupalorg-cli. However when I run
drupalorg issue:patch 3196147I getNID from argument is different from NID in issue branch name.. What's your preferred method of generating an interdiff?I realized that the previous patches were causing contextual links to not render when editing the default layout for a content type. My latest patch doesn't truly fix this, because it simply doesn't move the block description into the modal title when editing the default layout. This avoids the error that causes the contextual links not to render, but ideally we'd want the block description as the modal title in all situations. The problem is that if the current page is not a node (which is the case when editing the default layout), I don't know how to get the layout.
Comment #10
edurenye commentedHi @maskedjellybean, I never used this tool that you mention.
I just use normal
git diffcommand.I create a branch apply the previous patch, commit make my changes on top, then a diff to previous commit will give you the interdiff and a diff with dev branch will give you the patch.
Comment #11
johnwebdev commentedThanks for the work so far. I'm wondering if this should be a configurable behavior?
Any fieldable entity can have Layout Builder so we shouldn't assume that it always will be a node here, but can be any entity.
Does this target the override section storage? (If the node has been overriden), what happens if you try open Layout Builder Modal now on the default layout for the content type?
I think we can also use
OverridesSectionStorage::FIELD_NAMEinstead. But is there any way we can determine the actual section storage here?Comment #12
jayhuskinsThis approach does not work for newly created blocks, because they do not exist in the database. So if you create a block and then edit it before saving, then it won't match any of the components in the database and will get ignored.