MDL-59639 theme_boost: remember last visited tab
authorBas Brands <bas@moodle.com>
Thu, 27 Jun 2019 10:27:03 +0000 (12:27 +0200)
committerBas Brands <bas@moodle.com>
Tue, 6 Aug 2019 06:54:23 +0000 (08:54 +0200)
theme/boost/amd/build/loader.min.js
theme/boost/amd/build/loader.min.js.map
theme/boost/amd/src/loader.js
theme/boost/tests/behat/settingstabs.feature [new file with mode: 0644]

index bba4253..33e09e4 100644 (file)
Binary files a/theme/boost/amd/build/loader.min.js and b/theme/boost/amd/build/loader.min.js differ
index 2a85064..b090f5b 100644 (file)
Binary files a/theme/boost/amd/build/loader.min.js.map and b/theme/boost/amd/build/loader.min.js.map differ
index 88630ef..bb29acb 100644 (file)
@@ -61,6 +61,20 @@ define(['jquery', './tether', 'core/event'], function(jQuery, Tether, Event) {
         // Disables flipping the dropdowns up and getting hidden behind the navbar.
         jQuery.fn.dropdown.Constructor.Default.flip = false;
 
+        jQuery('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
+            var hash = jQuery(e.target).attr('href');
+            if (history.replaceState) {
+                history.replaceState(null, null, hash);
+            } else {
+                location.hash = hash;
+            }
+        });
+
+        var hash = window.location.hash;
+        if (hash) {
+           jQuery('.nav-link[href="' + hash + '"]').tab('show');
+        }
+
         // We need to call popover automatically if nodes are added to the page later.
         Event.getLegacyEvents().done(function(events) {
             jQuery(document).on(events.FILTER_CONTENT_UPDATED, function() {
diff --git a/theme/boost/tests/behat/settingstabs.feature b/theme/boost/tests/behat/settingstabs.feature
new file mode 100644 (file)
index 0000000..33cdacd
--- /dev/null
@@ -0,0 +1,13 @@
+@javascript @theme_boost
+Feature: Administration nav tabs back
+  When returning to the Administration page I want to see my last opened tab
+
+  Scenario: See last opened tab in site admin
+    Given I log in as "admin"
+    And I am on site homepage
+    And I click on "Site administration" "link"
+    And I click on "Users" "link"
+    And I click on "Browse list of users" "link"
+    And I should see "New filter"
+    When I press the "back" button in the browser
+    Then I should see "Cohorts"
\ No newline at end of file