diff --git a/core/modules/views/config/schema/views.display.schema.yml b/core/modules/views/config/schema/views.display.schema.yml index 16b0d1d2fb28ee1ef6a38c946b47d49446f7ab6c..511b0b93343cc1beef79230b2212a3693426da3d 100644 --- a/core/modules/views/config/schema/views.display.schema.yml +++ b/core/modules/views/config/schema/views.display.schema.yml @@ -43,6 +43,9 @@ views.display.page: context: type: string label: 'Context' + expanded: + type: boolean + label: 'Expanded' tab_options: type: mapping label: 'Tab options' diff --git a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php index 85c2350af22b2ce49bed1223386e39d8f8147c4f..f307ceeeb91b260752173aa591bcd057b6c1c466 100644 --- a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php +++ b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php @@ -127,6 +127,14 @@ public function getDescription() { return $this->loadView()->display_handler->getOption('menu')['description']; } + /** + * {@inheritdoc} + */ + public function isExpanded() { + return (bool) $this->loadView()->display_handler->getOption('menu')['expanded']; + } + + /** * {@inheritdoc} */ diff --git a/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php index 77f1b770a0ef8a2224360006fd750c6d9f5bf5ed..c23b26e1071777e64d8c5b766aebc42305ed4bb6 100644 --- a/core/modules/views/src/Plugin/views/display/Page.php +++ b/core/modules/views/src/Plugin/views/display/Page.php @@ -132,6 +132,7 @@ protected function defineOptions() { 'menu_name' => array('default' => 'main'), 'parent' => array('default' => ''), 'context' => array('default' => ''), + 'expanded' => array('default' => FALSE), ), ); $options['tab_options'] = array( @@ -239,7 +240,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ); $menu = $this->getOption('menu'); if (empty($menu)) { - $menu = array('type' => 'none', 'title' => '', 'weight' => 0); + $menu = array('type' => 'none', 'title' => '', 'weight' => 0, 'expanded' => FALSE); } $form['menu']['type'] = array( '#prefix' => '
', @@ -293,6 +294,12 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ), ), ); + $form['menu']['expanded'] = [ + '#title' => $this->t('Show as expanded'), + '#type' => 'checkbox', + '#default_value' => !empty($menu['expanded']), + '#description' => $this->t('If selected and this menu link has children, the menu will always appear expanded. '), + ]; // Only display the parent selector if Menu UI module is enabled. $menu_parent = $menu['menu_name'] . ':' . $menu['parent']; diff --git a/core/modules/views/src/Tests/Plugin/DisplayPageTest.php b/core/modules/views/src/Tests/Plugin/DisplayPageTest.php index 5ce2d3f2a4abea906a71808a992d2b70ab3df45b..7c7593dc0397a0de3a4c115464be5caf472874a4 100644 --- a/core/modules/views/src/Tests/Plugin/DisplayPageTest.php +++ b/core/modules/views/src/Tests/Plugin/DisplayPageTest.php @@ -136,6 +136,8 @@ public function testMenuLinks() { $this->assertTrue(isset($tree['system.admin']->subtree['views_view:views.test_page_display_menu.page_4'])); $menu_link = $tree['system.admin']->subtree['views_view:views.test_page_display_menu.page_4']->link; $this->assertEqual($menu_link->getTitle(), 'Test child (with parent)'); + $this->assertEqual($menu_link->isExpanded(), TRUE); + $this->assertEqual($menu_link->getDescription(), 'Sample description.'); } /** diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_menu.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_menu.yml index 814ad4ef534d01e54ccf066f4e14755bef60d7ab..a1eb3b56097588bbe72cb6eba79d30dd25accee1 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_menu.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_menu.yml @@ -91,10 +91,11 @@ display: type: normal title: 'Test child (with parent)' parent: system.admin - description: '' + description: 'Sample description.' menu_name: admin weight: 0 context: '0' + expanded: true defaults: title: false display_plugin: page