Block content #attributes not being added to top level render element.

Created on 24 December 2018, almost 6 years ago
Updated 5 February 2024, 11 months ago

The block content attributes aren't being output, because the #attributes property on the "content" child element of the render array isn't being copied to the top level element. If the block is a block content entity, then this will result in browser console errors if Quick Edit is enabled, such as:

Uncaught Error: Quick Edit could not associate the rendered entity field markup (with [data-quickedit-field-id="block_content/{BLOCK_ID}/{FIELD_NAME}/en/full"]) with the corresponding rendered entity markup: no parent DOMn node found with [data-quickedit-id="block_content/{BLOCK_ID}"].

Since the code in Drupal\views_block_area\Plugin\views\area\ViewsBlockArea::render() is based off code in Drupal\block\BlockViewBuilder::buildPreRenderableBlock, adapting code in Drupal\block\BlockViewBuilder::preRender to copy the attributes will address the issue.

πŸ› Bug report
Status

Closed: cannot reproduce

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡¦Ukraine paulrad

    I've tried but could not reproduce the reported issue. Please, provide steps to reproduce it.

  • πŸ‡¦πŸ‡ΉAustria tgoeg

    I lost track of the original cause/error for this as this is so long ago, but I think this also happens/triggers a similar error when setting up a search API view/search with facets placed above the search in a views_block_area and enabling AJAX.
    In this situation, I get
    {"message":"No facet link or facet blocks found."}', name: "AjaxError"
    I found a note stating:

    The problem is that the "block-facets-ajax" class is not being added to the rendered block.

    Sorry for being so vague, but maybe that helps in tracking this down somewhat.

  • Status changed to Needs work 11 months ago
  • πŸ‡ΊπŸ‡¦Ukraine paulrad

    If anyone of the contributors could retest it with the current dev version and update the patch, I'll be glad to merge it.

  • πŸ‡¦πŸ‡ΉAustria tgoeg

    Just tested with current stable and I cannot reproduce it anymore - at least not the problem I mentioned above.
    I think I am of no big help, then.

  • I'm not on a project currently using this module, and not sure I have to time to spin up a test soon, but part of the reason that the issue isn't reproducing visibly anymore is that QuickEdit was removed from Drupal core in 10.0.0 β†’ . Not having looked at the module code, it's possible block attributes are still missing, just that without QuickEdit, it's not obvious.

  • Status changed to Closed: cannot reproduce 11 months ago
Production build 0.71.5 2024