Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Unified Diff: chrome/browser/resources/settings/settings_page/main_page_behavior.js

Issue 1916323002: [MD settings] side nav routing to page sections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge with master Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/settings_page/main_page_behavior.js
diff --git a/chrome/browser/resources/settings/settings_page/main_page_behavior.js b/chrome/browser/resources/settings/settings_page/main_page_behavior.js
index 99dbc67c6181c689a6c3d63067f450ed323534c5..f00f038dd7d5627698a674cd3999f99d4fe01119 100644
--- a/chrome/browser/resources/settings/settings_page/main_page_behavior.js
+++ b/chrome/browser/resources/settings/settings_page/main_page_behavior.js
@@ -309,12 +309,14 @@ var MainPageBehaviorImpl = {
},
};
+
/** @polymerBehavior */
var MainPageBehavior = [
TransitionBehavior,
MainPageBehaviorImpl
];
+
/**
* TODO(michaelpg): integrate slide animations.
* @polymerBehavior RoutableBehavior
@@ -329,13 +331,23 @@ var RoutableBehaviorImpl = {
},
},
+ /**
+ * @param {string} section Name of the item to scroll into view.
+ */
+ scrollToSection: function(section) {
+ if (section) {
+ // TODO(dschuyler): Determine whether this setTimeout can be removed.
+ // See also: https://github.com/Polymer/polymer/issues/3629
+ setTimeout(function() {
+ this.getSection_(section).scrollIntoView();
+ }.bind(this));
+ }
+ },
+
/** @private */
currentRouteChanged_: function(newRoute, oldRoute) {
- // route.section is only non-empty when the user is within a subpage.
- // When the user is not in a subpage, but on the Basic page, route.section
- // is an empty string.
- var newRouteIsSubpage = newRoute && newRoute.section;
- var oldRouteIsSubpage = oldRoute && oldRoute.section;
+ var newRouteIsSubpage = newRoute && newRoute.subpage.length;
+ var oldRouteIsSubpage = oldRoute && oldRoute.subpage.length;
if (!oldRoute && newRouteIsSubpage) {
// Allow the page to load before expanding the section. TODO(michaelpg):
@@ -357,6 +369,8 @@ var RoutableBehaviorImpl = {
var section = this.getSection_(newRoute.section);
if (section)
this.expandSection(section);
+ } else if (newRoute && newRoute.section) {
+ this.scrollToSection(newRoute.section);
}
},
@@ -372,6 +386,7 @@ var RoutableBehaviorImpl = {
},
};
+
/** @polymerBehavior */
var RoutableBehavior = [
MainPageBehavior,

Powered by Google App Engine
This is Rietveld 408576698