I have a content type that is displayed with Layout Builder. When I view it in default mode, the Quick Edit option does not appear in the contextual menu. This is because none of the fields have the data-quickedit-field-id
attribute.
I spent a couple of days chasing this down. Apparently the issue comes up in this function in core/modules/layout_builder/src/QuickEditIntegration.php
.
private function supportQuickEditOnComponent(array $component, FieldableEntityInterface $entity) {
if (isset($component['content']['#field_name'], $component['#base_plugin_id']) && $component['#base_plugin_id'] === 'field_block' && $entity->hasField($component['content']['#field_name'])) {
return $entity->getFieldDefinition($component['content']['#field_name'])->isDisplayConfigurable('view');
}
return FALSE;
}
When entityViewAlter
calls supportQuickEditOnComponent
, the $component array contains an unexpected nested array...
and all the stuff that's supposed to be inside content
is instead nested in a subarray [0]
. As a result of that, the function returns false
and none of the fields get added to $plugin_ids_to_update
and thus they are not parsed inside this loop in entityViewAlter
:
foreach ($plugin_ids_to_update as $delta => $regions) {
foreach ($regions as $region => $uuids) {
foreach ($uuids as $uuid => $component) {
$build['_layout_builder'][$delta][$region][$uuid]['content']['#view_mode'] = static::getViewModeId($entity, $display, $delta, $uuid, $sections_hash);
}
}
}
... which is where the view mode ID is assigned that enables that data-quickedit-field-id
attribute to be added by Quick Edit later.
I've "fixed" this by hacking QuickEditIntegration.php
in two places, collapsing the subarray [0]
into the main $component
array. I know this is not the right way to do it. What could be causing these Layout Builder components to be populated into a subarray instead of where QuickEditIntegration is expecting to find them?