Problem/Motivation

Steps to reproduce:

Install Layout Builder module
Manage Display of one content type, like "Basic Page". Under "Custom Display Settings", enable Full view mode
Manage Display of a different content type, like "Article".

Expected

Overrides can be enabled for Articles

Actual

No checkbox present, overrides cannot be enabled

Proposed resolution

Limit the query to the specific entity type and bundle.

Remaining tasks

Write tests

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Original report

I've been building a mega menu in my dev environment based on this tutorial . I updated that environment to 8.7 and everything I was working on broke due to the disappearance of the ability to customize layouts of individual menu items.

How to Reproduce

  1. Update to 8.7
  2. Install Layout Builder, Menu Item Extras
  3. Go to /admin/structure/menu/my_menu/display to view location of missing settings

Expected Behavior

The second checkbox to allow menu items to have custom layouts should still be available.

What Happens Instead

The second checkbox is missing. Features that depend on this setting break. I can no longer manage layouts on individual menu items.

Comments

Waxwing created an issue. See original summary.

jpieper’s picture

Title: Checkbox to allow custom menu links to have custom layouts gone » No longer able to customize menu links with layout builder
tim.plunkett’s picture

Status: Active » Postponed (maintainer needs more info)

Hmm, I'm having trouble reproducing the bug. After installing Menu Item Extras and Layout Builder, I see both checkboxes on admin/structure/menu/manage/my-menu/display and can customize the layout of individual menu items.

jpieper’s picture

@tim.plunkett I installed a fresh site locally and was able to get this to work without issue just as you described.

I went back to the site with which I'm having issues to see wha's going on. I checked inthe LayoutBuilderEntityViewDisplayForm.php file and verified my menu's mode via $this->entity->getMode(). It returns "default". However, $this->isCanonicalMode($this->entity->getMode()) is returning false.

I looked further into isCanonicalMode(), specifically the following query:

 $query = $this->entityTypeManager->getStorage($this->entity->getEntityTypeId())->getQuery()
        ->condition('status', TRUE)
        ->condition('mode', $canonical_mode);
      return !$query->count()->execute();

This query is returning the 'full' view mode of an unrelated content type:

array:1 [
  "node.content_type.full" => "node.content_type.full"
]

This doesn't seem to be correct but I'm not sure what might be causing this.

tim.plunkett’s picture

Title: No longer able to customize menu links with layout builder » Cannot enable overrides for any bundle if another bundle has full view mode enabled
Version: 8.7.x-dev » 8.8.x-dev
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs review
Issue tags: +Blocks-Layouts, +Needs tests
Related issues: +#2955065: Customized layout does not display for node with customizations enabled when using full content view mode
StatusFileSize
new907 bytes

Oh, wow. I was able to reproduce.
The problem occurs if you have the full view mode enabled for any other bundle on the site. Because the query is not nearly specific enough.

jpieper’s picture

I applied the patch in #5 and it resolves the issue with menu links. The option to allow each entity of the given type to have its layout customized now shows up as expected. When that option is checked I've verified that the "Layout" tab is available, too.

I noticed while testing that this issue was occurring in various content types in addition to the menu link issues. It's working as expected for those content types as well.

jpieper’s picture

Status: Needs review » Reviewed & tested by the community
tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett
Status: Reviewed & tested by the community » Needs work

Thanks for the review! I'm glad to hear it works.
Before it can be committed, it needs automated tests. Working on that.

tim.plunkett’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new1.61 KB
new2.49 KB
portulaca’s picture

I'm also affected by this, although I'm not using the Menu Item Extras, and I *don't* have the Full content enabled on any Content type.

Where else should I check where the Full content might be enabled?

I only use Layout Builder on Articles.

Anyway, I applied the patch from #5, and everything seems to be working now.

I see the option Allow each content item to have its layout customized., I can enable it, I can override Layout for individual nodes of type where LB is enabled, and I can see the Layout tab on those nodes.

The last submitted patch, 9: 3053529-canonical-9-FAIL.patch, failed testing. View results

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned

It will fail if "Full" is on for *any* entity type, because I was horribly sloppy when writing the original query :(

Anyway, this should be good to go now

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Nice catch + fix.

xjm’s picture

Priority: Normal » Major

Promoting to major given the number of reports here. Thanks!

  • xjm committed c417760 on 8.8.x
    Issue #3053529 by tim.plunkett, Waxwing, portulaca: Cannot enable...

  • xjm committed 16a6d2b on 8.7.x
    Issue #3053529 by tim.plunkett, Waxwing, portulaca: Cannot enable...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.8.x and cherry-picked to 8.7.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.