Comments

benjy created an issue. See original summary.

benjy’s picture

StatusFileSize
new866 bytes

I had a temporary workaround that works for block_content blocks, not sure exactly how the right way to go about generating the correct contextual links for all entities just yet. I was trying with:

$entity = \Drupal::entityManager()->loadEntityByUuid($block->getBaseId(), $block->getDerivativeId());
'#contextual_links' => [$entity_type => ['route_parameters' => $entity->id()]];

But for some reason, the act of loading the entity made the page a 404, will need to look into that further.

Also, any errors in PageBlockDisplayVariant give you a white screen because of the suppressed errors VariantCollection::sort().

taherpro’s picture

This Patch works for block_content blocks. Thanks benjy!

But the contextual links for views listed on the pages using page manager are breaking.

mmenavas’s picture

Is anyone else still experiencing this issue?

Contextual links show up for me when I add a View Block to a Block Page variant. However they don't show up on Content Blocks. I'm using the dev version.

claudiu.cristea’s picture

@mmenavas, try to apply the patch from #2. For me #2 is fixing:

If a views block has the Other > Contextual Links enabled, it shows the contextual links (both: the block & the view) but they are not woking. It looks like a z-index issue.

However, I think that \Drupal\Core\Block\BlockPluginInterface should define a new method getContextualLinks() and add the links in BlockBase. In that way, the implementations will only have to return the links in the new method. That would made our case simple, without the need of building the original block.

'#contextual_links' => $block->getContextualLinks()

mmenavas’s picture

@claudiu.cristea the patch from #2 does provide contextual links for Content Blocks in a Variant, but as a side effect it duplicates the contextual links for Views Blocks.

I'm using Drupal 8.0.1, Bartik theme, Page Manager alpha20, CTools alpha20, and PHP 5.6.14.

imre.horjan’s picture

It works for me using content blocks.

kenorb’s picture

Status: Active » Needs review
kenorb’s picture

Status: Needs review » Needs work

The last submitted patch, 2: page-manager-contextual-temp.patch, failed testing.

thebruce’s picture

Not sure if this is related but - I am able to get a contextual link block to appear on pages that have panels page variants but only for the very first variant. All other variants are unable to get contextual links. If you change the variant in the first position to another - then that variant can get the contextual link block but not the former.

I tried this patch just for kicks, knowing that it applied to block panels. As expected it did not affect this issue. Happy to create a separate issue but it seems related.

Sorry - found the correct issue: https://www.drupal.org/node/2649702

huzooka’s picture

I have a similar hack to get the contextual links back, but I suggest to work around this in buildBlock(). We can avoid that the same block is builded twice and we also need the contextual-region CSS class on the block (which is the only (default) piece in the renderable we get).

huzooka’s picture

Patch attached, but it fixes only block_content entities, (so e.g. menu blocks will still miss contextual links).

huzooka’s picture

kyuubi’s picture

Hi,

Is there any update on a fix for this that can work across all entities?

benjy’s picture

@kyuubi, if you're using Panels then the issue is fixed in HEAD but we've been using an older version because HEAD has been a bit flaky.

You can try this fix manually, in Drupal\panels\Plugin\DisplayBuilder\StandardDisplayBuilder::buildRegions()

    // $block_render_array['content'] = $block->build(); - Underneath this line, insert the following:

    if (isset($block_render_array['content']['#contextual_links'])) {
        $block_render_array['#contextual_links'] = $block_render_array['content']['#contextual_links'];
     }
benjy’s picture

StatusFileSize
new1.77 KB

Here's the actual patch we're using back ported from head.

kyuubi’s picture

Hi benjy,

Thank you for your help!

Cheers,

matt_paz’s picture

I think this might still be an issue and the patch is outdated.
Can anyone confirm?

rbosscher’s picture

I just encountered this issue, so I can confirm this is still an issue.

unfortunately the patch of huzooka (#14) didn't help

The patch (#17) is actually allready in the Panels 8.x-4.3 version, so it doesn't need to be patched. That patch causes, I think, to put the contextual links twice on the same block wich just is not a good idea (#1914966: Nested contextual links triggers don't work well)

The contextual links started working again when I removed the following line:

-            foreach (['#attributes', '#contextual_links'] as $property) {
+           foreach (['#attributes'] as $property) {

I think this might also be related to: #2743353: Contextual links double trigger And I will post the patch there, as that issue is in the right module.

geek-merlin’s picture

Status: Needs work » Reviewed & tested by the community

This issue looks quite confusing to me... What i can see:

* #17 does not apply agains page_manager (but against panels)
* #14 still applies against current dev and fixes the issue to me.
The code makes sense.

Status NW was incorrect, should be NR as of #14.

So setting RTBC.

pfrenssen’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

This doesn't have a test yet.

claudiu.cristea’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new3.26 KB
new8.44 KB
new8.22 KB

Tests provided.

manuel.adan’s picture

Version: 8.x-1.x-dev » 8.x-4.x-dev

Version changed to the current -dev branch (4.x). Automated tests should now be triggered.

claudiu.cristea’s picture

StatusFileSize
new4.26 KB
new8.82 KB

@manuel.adan, thank you. I forgot to select the correct branch.

Status: Needs review » Needs work

The last submitted patch, 25: 2601004-25.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

manuel.adan’s picture

+++ b/src/Plugin/DisplayVariant/PageBlockDisplayVariant.php
@@ -182,30 +182,36 @@ class PageBlockDisplayVariant extends BlockDisplayVariant implements PluginWizar
+
+    if ($content === NULL || Element::isEmpty($content)) {
       // Abort rendering: render as the empty string and ensure this block is
       // render cached, so we can avoid the work of having to repeatedly
       // determine whether the block is empty. E.g. modifying or adding entities
       // could cause the block to no longer be empty.
-      $build = [
+      return [
         '#markup' => '',
         '#cache' => $build['#cache'],
       ];
     }

Empty block test fail after this PageBlockDisplayVariant::buildBlock refactoring. Cache metadata is expected to be merged for empty blocks, to indicate why they are empty, but after the changes it is returned directly with no cache merging.

I back the buildBlock to its initial implementation, but adding the new code related to the contextual links.

manuel.adan’s picture

Status: Needs work » Needs review
claudiu.cristea’s picture

@manuel.adan, yeah, I was thinking about that, Thank you for fixing the bug I've been introduced. However, as I contributed, I cannot RTBC.

claudiu.cristea’s picture

StatusFileSize
new643 bytes
new7.93 KB

State that the new module is a testing module.

pfrenssen’s picture

StatusFileSize
new6.4 KB

Here is a version of the patch from #30 that only includes the test. This is just to see that the test correctly fails when the functionality is missing. No changes have been made.

Status: Needs review » Needs work

The last submitted patch, 31: 2601004-30-tests-only.patch, failed testing. View results

pfrenssen’s picture

Status: Needs work » Reviewed & tested by the community

Patch looks good! The test fails correctly and the code looks good.

I only have one small remark but this is too trivial to block the patch on.

+  /**
+   * Tests the contextual links the placed blocks.
+   */

This should be Tests the contextual links of the placed blocks..

manuel.adan’s picture

Status: Reviewed & tested by the community » Fixed

It looks fine for me too. Thank you all!

Status: Fixed » Closed (fixed)

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