diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 534925c9132..a049afc9cbc 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -9,7 +9,6 @@ namespace Drupal\views\Plugin\views\display; use Drupal\Component\Plugin\DependentPluginInterface; use Drupal\Component\Utility\Html; -use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheableMetadata; @@ -1130,7 +1129,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte ); } - $display_comment = Unicode::substr($this->getOption('display_comment'), 0, 10); + $display_comment = views_ui_truncate($this->getOption('display_comment'), 80); $options['display_comment'] = array( 'category' => 'other', 'title' => $this->t('Administrative comment'), diff --git a/core/modules/views_ui/src/Tests/ViewEditTest.php b/core/modules/views_ui/src/Tests/ViewEditTest.php index 3595aa24d3d..b68dee01690 100644 --- a/core/modules/views_ui/src/Tests/ViewEditTest.php +++ b/core/modules/views_ui/src/Tests/ViewEditTest.php @@ -45,13 +45,18 @@ class ViewEditTest extends UITestBase { } /** - * Tests the machine name form. + * Tests the machine name and administrative comment forms. */ - public function testMachineNameOption() { + public function testOtherOptions() { $this->drupalGet('admin/structure/views/view/test_view'); // Add a new attachment display. $this->drupalPostForm(NULL, array(), 'Add Attachment'); + // Test that a long administrative comment is truncated. + $edit = array('display_comment' => 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen'); + $this->drupalPostForm('admin/structure/views/nojs/display/test_view/attachment_1/display_comment', $edit, 'Apply'); + $this->assertText('one two three four five six seven eight nine ten eleven twelve thirteen fourteen...'); + // Change the machine name for the display from page_1 to test_1. $edit = array('display_id' => 'test_1'); $this->drupalPostForm('admin/structure/views/nojs/display/test_view/attachment_1/display_id', $edit, 'Apply');