Score:3

QuickEditIntegration can't process components for Quick Edit

cn flag

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...

snapshot of JSON structure

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?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.