Commit b85ec521 authored by alexpott's avatar alexpott
Browse files

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

parent 822835f0
......@@ -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());
}
/**
......
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