Skip to content
Snippets Groups Projects
Commit b85ec521 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2463579 by tstoeckler: Add an ellipsis to truncated comment titles

parent 822835f0
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -301,7 +301,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) {
// 2) Strip out all HTML tags
// 3) Convert entities back to plain-text.
$comment_text = $comment->comment_body->processed;
$comment->setSubject(Unicode::truncate(trim(Html::decodeEntities(strip_tags($comment_text))), 29, TRUE));
$comment->setSubject(Unicode::truncate(trim(Html::decodeEntities(strip_tags($comment_text))), 29, TRUE, TRUE));
// Edge cases where the comment body is populated only by HTML tags will
// require a default subject.
if ($comment->getSubject() == '') {
......
......@@ -220,12 +220,12 @@ public function testAutoFilledSubject() {
$body_text = 'Lorem ipsum Lorem ipsum Loreming ipsum Lorem ipsum';
$comment1 = $this->postComment(NULL, $body_text, '', TRUE);
$this->assertTrue($this->commentExists($comment1), 'Form comment found.');
$this->assertEqual('Lorem ipsum Lorem ipsum', $comment1->getSubject());
$this->assertEqual('Lorem ipsum Lorem ipsum', $comment1->getSubject());
// Break at 29 characters where there's no boundary before that.
$body_text2 = 'LoremipsumloremipsumLoremingipsumLoremipsum';
$comment2 = $this->postComment(NULL, $body_text2, '', TRUE);
$this->assertEqual('LoremipsumloremipsumLoremingi', $comment2->getSubject());
$this->assertEqual('LoremipsumloremipsumLoreming', $comment2->getSubject());
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment