Problem/Motivation

Contextual links are not displayed due to to #3035140: Blocks plugin calls $block->build() twice.

Calling build() twice was a good catch so we should add in preRender(), block is built once. Note that #contextual_links are added in `Drupal\block\BlockViewBuilder::preRender()` in similar way.

Steps to reproduce

Add a menu block using context, note that "edit menu" contextual links does not appear.
(link are added by `hook_block_view_BASE_BLOCK_ID_alter()` at `menu_ui_block_view_system_menu_block_alter()`)

Proposed resolution

Add links in prerender including #attributes.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

silverham created an issue. See original summary.

silverham’s picture

Status: Active » Needs review
StatusFileSize
new3.39 KB

Patch to module.

Status: Needs review » Needs work
paulocs’s picture

Status: Needs work » Needs review
deaom’s picture

Status: Needs review » Reviewed & tested by the community

I could not reproduce the issue of contextual links not being present without the patch. But I do see the point @silverham is trying to make. Did test the patch and it seems to not break anything. I think this can be committed to dev branch, and therefore marking it as RTBC. I'm just not a fan of long comments and would shorten that to just what that part of code does not why it does that.

silverham’s picture

@DeaOm - I just copy/paste the same code as Drupal core but happy for any adjustment or shortening. :-)

  • paulocs committed 58118f7 on 8.x-4.x authored by silverham
    Issue #3175667 by silverham, paulocs, DeaOm: Add (Back) Contextual links...
paulocs’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @silverham and @DeaOm.

Fixed in dev branch!

Status: Fixed » Closed (fixed)

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