MDL-73329 admin: improve detection of the admin search page.

After a query has been performed, the individual tab content
(it's settings links) isn't rendered to the page. In this case
we should redirect the user back to initial page without the
query parameter, in order for the tab content to load.
This commit is contained in:
Paul Holden
2021-12-10 14:00:38 +00:00
parent 222c8cc77c
commit becf3bd15c
+4 -2
View File
@@ -626,13 +626,15 @@ class secondary extends view {
* Load the site admin navigation
*/
protected function load_admin_navigation(): void {
global $PAGE;
$settingsnav = $this->page->settingsnav;
$node = $settingsnav->find('root', self::TYPE_SITE_ADMIN);
// We need to know if we are on the main site admin search page. Here the navigation between tabs are done via
// anchors and page reload doesn't happen. On every nested admin settings page, the secondary nav needs to
// exist as links with anchors appended in order to redirect back to the admin search page and the corresponding
// tab.
$isadminsearchpage = $this->page->pagetype === 'admin-search';
// tab. Note this value refers to being present on the page itself, before a search has been performed.
$isadminsearchpage = $PAGE->url->compare(new \moodle_url('/admin/search.php', ['query' => '']), URL_MATCH_PARAMS);
if ($node) {
$siteadminnode = $this->add($node->text, "#link$node->key", null, null, 'siteadminnode');
if ($isadminsearchpage) {