Commit a1a08feb authored by alexpott's avatar alexpott

Issue #2379083 by olli, Wim Leers: Regression (again): Menu contextual links...

Issue #2379083 by olli, Wim Leers: Regression (again): Menu contextual links no longer visible in menu blocks, when block caching is enabled
parent 7d36a7c3
......@@ -120,7 +120,7 @@ function menu_ui_block_view_system_menu_block_alter(array &$build, BlockPluginIn
// Add contextual links for system menu blocks.
$menus = menu_list_system_menus();
$menu_name = $block->getDerivativeId();
if (isset($menus[$menu_name]) && isset($build['content'])) {
if (isset($menus[$menu_name])) {
$build['#contextual_links']['menu'] = array(
'route_parameters' => array('menu' => $menu_name),
);
......
......@@ -9,6 +9,7 @@
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Menu\MenuLinkInterface;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\system\Entity\Menu;
......@@ -533,6 +534,12 @@ public function testBlockContextualLinks() {
$this->assertResponse(200);
$json = Json::decode($response);
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '">Configure block</a></li><li class="entitymenuedit-form"><a href="' . base_path() . 'admin/structure/menu/manage/tools">Edit menu</a></li></ul>');
// Test the contextual links are available when block caching is enabled.
$this->drupalPostForm('admin/structure/block/manage/' . $block->id(), ['settings[cache][max_age]' => Cache::PERMANENT], t('Save block'));
$this->drupalGet('test-page');
$id = 'block:block=' . $block->id() . ':|menu:menu=tools:';
$this->assertRaw('<div data-contextual-id="'. $id . '"></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment