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

Side by Side Diff: chrome/browser/resources/settings/settings_page/main_page_behavior.js

Issue 2506793002: MD Settings: Fix Back navigation from section route to BASIC route. (Closed)
Patch Set: address comments Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/basic_page_browsertest.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Responds to route changes by expanding, collapsing, or scrolling to sections 6 * Responds to route changes by expanding, collapsing, or scrolling to sections
7 * on the page. Expanded sections take up the full height of the container. At 7 * on the page. Expanded sections take up the full height of the container. At
8 * most one section should be expanded at any given time. 8 * most one section should be expanded at any given time.
9 * @polymerBehavior MainPageBehavior 9 * @polymerBehavior MainPageBehavior
10 */ 10 */
(...skipping 12 matching lines...) Expand all
23 /** 23 /**
24 * @param {!settings.Route} newRoute 24 * @param {!settings.Route} newRoute
25 * @param {settings.Route} oldRoute 25 * @param {settings.Route} oldRoute
26 */ 26 */
27 currentRouteChanged: function(newRoute, oldRoute) { 27 currentRouteChanged: function(newRoute, oldRoute) {
28 // Scroll to the section except for back/forward. Also scroll for any 28 // Scroll to the section except for back/forward. Also scroll for any
29 // back/forward navigations that are in-page. 29 // back/forward navigations that are in-page.
30 var oldRouteWasSection = 30 var oldRouteWasSection =
31 !!oldRoute && !!oldRoute.parent && !!oldRoute.section && 31 !!oldRoute && !!oldRoute.parent && !!oldRoute.section &&
32 oldRoute.parent.section != oldRoute.section; 32 oldRoute.parent.section != oldRoute.section;
33
34 if (oldRouteWasSection && newRoute == settings.Route.BASIC) {
35 this.scroller.scrollTop = 0;
36 return;
37 }
38
33 var scrollToSection = 39 var scrollToSection =
34 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection; 40 !settings.lastRouteChangeWasPopstate() || oldRouteWasSection;
35 41
36 // If this is the first route, or the page was hidden, allow the page to 42 // If this is the first route, or the page was hidden, allow the page to
37 // render before expanding the section. 43 // render before expanding the section.
38 if (!oldRoute && newRoute.contains(settings.getCurrentRoute()) || 44 if (!oldRoute && newRoute.contains(settings.getCurrentRoute()) ||
39 this.scrollHeight == 0) { 45 this.scrollHeight == 0) {
40 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection)); 46 setTimeout(this.tryTransitionToSection_.bind(this, scrollToSection));
41 } else { 47 } else {
42 this.tryTransitionToSection_(scrollToSection); 48 this.tryTransitionToSection_(scrollToSection);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 return /** @type {?SettingsSectionElement} */( 274 return /** @type {?SettingsSectionElement} */(
269 this.$$('settings-section[section="' + section + '"]')); 275 this.$$('settings-section[section="' + section + '"]'));
270 }, 276 },
271 }; 277 };
272 278
273 /** @polymerBehavior */ 279 /** @polymerBehavior */
274 var MainPageBehavior = [ 280 var MainPageBehavior = [
275 settings.RouteObserverBehavior, 281 settings.RouteObserverBehavior,
276 MainPageBehaviorImpl, 282 MainPageBehaviorImpl,
277 ]; 283 ];
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/basic_page_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698