diff --git a/core/modules/comment/src/CommentLinkBuilder.php b/core/modules/comment/src/CommentLinkBuilder.php index 91640ca..a57d21c 100644 --- a/core/modules/comment/src/CommentLinkBuilder.php +++ b/core/modules/comment/src/CommentLinkBuilder.php @@ -157,16 +157,18 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra if ($commenting_status == CommentItemInterface::OPEN) { if ($this->currentUser->hasPermission('post comments')) { - // We decide the link to the comment-add form using our own view - // mode. + // If our own view mode has visible comments, we determine the + // link for the comment-add form using its formatter settings. + // If not, we use the formatter settings for 'full' view mode, + // which means that the comment-add link for a teaser can link + // to the full node page. (This is default behavior.) $display = $this->entityManager->getStorage('entity_view_display') ->load($entity->getEntityTypeId() . '.' . $entity->bundle() . '.' . $view_mode); - if (!$display) { - $display = $this->entityManager->getStorage('entity_view_display') - ->load($entity->getEntityTypeId() . '.' . $entity->bundle() . '.default'); - } $formatter_options = $display - ? $display->getComponent($field_name): NULL; + ? $display->getComponent($field_name) : NULL; + if (!$formatter_options) { + $formatter_options = $formatter_options_full; + } // Show the "post comment" link if the form is on another page, or // if there are existing comments that the link will skip past.