Verified Commit c3c9dd1e authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #2978024 by Akhil Babu, dan612, smustgrave, quietone, elaman,...

Issue #2978024 by Akhil Babu, dan612, smustgrave, quietone, elaman, harshil_jadav: Allow "Content ID from URL" contextual filter to recognize node previews
parent e16d8e0f
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -60,7 +60,9 @@ public static function create(ContainerInterface $container, array $configuratio
   * {@inheritdoc}
   */
  public function getArgument() {
    if (($node = $this->routeMatch->getParameter('node')) && $node instanceof NodeInterface) {
    // Get the node object from current route.
    $node = $this->routeMatch->getParameter('node') ?? $this->routeMatch->getParameter('node_preview');
    if ($node instanceof NodeInterface) {
      return $node->id();
    }
  }
+6 −0
Original line number Diff line number Diff line
@@ -168,6 +168,12 @@ public function testArgumentDefaultNode() {
    $this->assertSession()->elementTextContains('xpath', '//*[@id="block-' . $id . '"]', $node1->getTitle());
    $this->drupalGet('node/' . $node2->id());
    $this->assertSession()->elementTextContains('xpath', '//*[@id="block-' . $id . '"]', $node2->getTitle());

    // Check the view from node preview page.
    $node3 = $this->drupalCreateNode(['title' => 'Title 1', 'type' => 'page']);
    $this->drupalGet($node3->toUrl('edit-form'));
    $this->submitForm(['title[0][value]' => 'Title 2'], 'Preview');
    $this->assertSession()->elementTextContains('xpath', '//*[@id="block-' . $id . '"]', $node3->getTitle());
  }

  /**