Problem/Motivation
From discussion in #2938182-9: Design intuitive affordances for Layout Builder (for illustrating which parts of the page are editable in a given context)
One thing that could be very confusing to site builders is that
- Using the Layout Builder, Layouts are populated with blocks
- You can configure blocks you add and existing blocks in the layout
- You configure the existing blocks in the Layout Builder via contextual links
- There will usually be other blocks on the page, but out of the Layout Builder controlled sections
- For the blocks outside of the sections: You(if you have permission) also can configure these blocks in the Layout Builder via contextual links
- If you have Setting Tray enabled configuring the non-Layout Builder blocks happens in the same place as Layout Builder blocks
I think especially if you are configuring a layout override, say for a node, the user may expect that changes they make to any blocks when using the Layout Builder would be overrides just for that node.
But of course if they configure any block not controlled by Layout Builder, say a search block in a sidebar region, this will be global change and has nothing to do with the Layout override.
So hopefully we can at least say
When a user is configuring a layout in Layout Builder they should not be able to edit blocks not controlled by Layout Builder.
I don't think this would really a burden for users and would remove a lot of confusion.
A simple way to do this would be to remove all block contextual links form blocks not controlled by Layout Builder during layout administration.
I think is important because the whole idea of contextual links is that you can make changes in a given context. So I think it would reasonable for the user to assume they can edit blocks "in the context of the layout"(whether default or override).
Proposed resolution
Remove all contextual links for block outside of the layout when using layout builder
There is existing issue #3002608: Remove contextual links not related to layout administration inside layout builder blocks. This could have been one issue but since that one is RTBC I wanted to make this seperate one.
Although the code will be about the same some may think the other issue is a good idea and this one is not. Hopefully everyone will think both are great ideas 😜
Remaining tasks
do it
User interface changes
No contextual links will be available when using the Layout builder that are outside of the Layout builder admin area.
API changes
none
Data model changes
None
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3028191-2_plus_3002608-19.patch | 18.59 KB | tedbow |
| #2 | 3028191-2-do-not-test.patch | 3.32 KB | tedbow |
Issue fork drupal-3028191
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:
- 3028191-when-using-layout
changes, plain diff MR !5400
Comments
Comment #2
tedbowOk this patch starts from #3002608-19: Remove contextual links not related to layout administration inside layout builder blocks because that has almost all the code necessary.
So it also will remove all non-layout Builder contextual for block inside the Layout Builder. So if you place View block it doesn't have the "Edit View" block. See that issue for why if is not apparent.
So for not assuming that issue would get in first. Maybe we should just fold it in.
Comment #5
andypostViews also using to suppress contextual #3039248: Deprecate views_ui_contextual_links_suppress(), views_ui_contextual_links_suppress_push(), views_ui_contextual_links_suppress_pop()
Comment #6
xjmComment #7
xjmComment #8
andypostI think both issues needs common ability to control contextual additions to render element
Like
Comment #9
tim.plunkettComment #12
bkosborneComment #18
bkosborneHere's a quick fix you can place in a custom module to remove all contextual links that are not used by Layout Builder:
Comment #22
srishtiiee commentedComment #24
smustgrave commentedRebased to run the test-only feature
Tested this manually on a Standard profile install with layout builder enabled
Checking the title block I see the contextual links
Applying the MR and refreshing my browser I can no longer see the contextual links for the title.
Did verify the contextual links within the layout are still functional.
Went to a random non layout builder page and verified contextual links are unaffected there too.
Comment #25
srishtiiee commentedTest needs to be fixed
Comment #27
narendrarComment #28
yash.rode commentedTested this manually, It is working as expected and the test coverage is also thorough.
Comment #29
yash.rode commentedComment #33
lauriiiCommitted 6959691 and pushed to 11.x. Also cherry-picked to 10.2.x. Thanks!
Comment #35
hydra commentedTook me a long road to come here. For everyone wondering where their contextual links went when using layout_builder translations with https://www.drupal.org/project/drupal/issues/2946333 or https://www.drupal.org/project/layout_builder_st, the newly introduced JS in this issue removes them.
I opened an issue for that in the layout_builder_st issue queue: https://www.drupal.org/project/layout_builder_st/issues/3411037
Not sure if this is the right place either...
Just wanted to let this comment here for others who are debugging this.
Comment #36
joegl commentedWe have a custom module to create block groups in layout builder. The child blocks in the parent block group have their own contextual links defined by the module, and do not have the
layout_builder_block:start to the contextual ID. This change removed the contextual links for the child blocks, and they can no longer be edited, removed, moved, etc.,What is the best way to approach changes to the custom module to support this change? Adding the colon
:to the end here seems a bit heavy handed. If it wasn't there, we could at least update our module to use thelayout_builder_block_prefix.I'm tempted to patch this change out for now on our sites as it makes a lot of assumptions.
Comment #37
joegl commentedOur solution for this was to patch the one line and adjust the condition to allow our custom blocks as well:
I'd still like to see something more comprehensive to allow customizations like ours if possible. Again, this change makes a lot of assumptions about the desired user experience and the approach here is very heavy-handed.