From b72a2b119434bbb9ba34fdc3e484175b25d88826 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Sat, 14 May 2022 15:53:09 +0100 Subject: [PATCH] Issue #2314443 by olli, Lendude, immaculatexavier, dawehner: Changing view name does not update page title in views ui (cherry picked from commit fe3be7e13e8acaceb44a1a9d9e2a7881bcc10c26) --- .../views/src/Ajax/ReplaceTitleCommand.php | 3 ++- .../src/FunctionalJavascript/DisplayTest.php | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/core/modules/views/src/Ajax/ReplaceTitleCommand.php b/core/modules/views/src/Ajax/ReplaceTitleCommand.php index 90e462abfa3..6da95a7c36a 100644 --- a/core/modules/views/src/Ajax/ReplaceTitleCommand.php +++ b/core/modules/views/src/Ajax/ReplaceTitleCommand.php @@ -34,7 +34,8 @@ class ReplaceTitleCommand implements CommandInterface { public function render() { return [ 'command' => 'viewsReplaceTitle', - 'selector' => $this->title, + 'title' => $this->title, + 'siteName' => \Drupal::config('system.site')->get('name'), ]; } diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php index 9aaec96f087..edd1bb4bf5b 100644 --- a/core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php @@ -81,6 +81,28 @@ class DisplayTest extends WebDriverTestBase { $this->assertNotEmpty($element); } + /** + * Tests setting the administrative title. + */ + public function testRenameDisplayAdminName() { + $titles = ['New admin title', '']; + foreach ($titles as $new_title) { + $this->drupalGet('admin/structure/views/view/test_content_ajax'); + $page = $this->getSession()->getPage(); + + $page->findLink('Edit view name/description')->click(); + $this->getSession()->executeScript("document.title = 'Initial title | " . \Drupal::config('system.site')->get('name') . "'"); + + $admin_name_field = $this->assertSession() + ->waitForField('Administrative name'); + $dialog_buttons = $page->find('css', '.ui-dialog-buttonset'); + $admin_name_field->setValue($new_title); + + $dialog_buttons->pressButton('Apply'); + $this->assertJsCondition("document.title === '" . $new_title . " (Content) | " . \Drupal::config('system.site')->get('name') . "'"); + } + } + /** * Tests contextual links on Views page displays. */