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

Unified Diff: chrome/browser/resources/settings/route.js

Issue 2297663008: MD Settings: Prevent unexpected scrolling to section on popstates. (Closed)
Patch Set: Created 4 years, 3 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/route.js
diff --git a/chrome/browser/resources/settings/route.js b/chrome/browser/resources/settings/route.js
index 81e872d68458129929b598406914dce4bf599215..929724efeb537edc4e675ebd62bbc9b47e7fad2e 100644
--- a/chrome/browser/resources/settings/route.js
+++ b/chrome/browser/resources/settings/route.js
@@ -277,13 +277,14 @@ cr.define('settings', function() {
* Helper function to set the current route and notify all observers.
* @param {!settings.Route} route
* @param {!URLSearchParams} queryParameters
+ * @param {boolean} isPopstate
*/
- var setCurrentRoute = function(route, queryParameters) {
+ var setCurrentRoute = function(route, queryParameters, isPopstate) {
var oldRoute = currentRoute_;
currentRoute_ = route;
currentQueryParameters_ = queryParameters;
for (var observer of routeObservers_)
- observer.currentRouteChanged(currentRoute_, oldRoute);
+ observer.currentRouteChanged(currentRoute_, oldRoute, isPopstate);
};
/** @return {!settings.Route} */
@@ -312,7 +313,7 @@ cr.define('settings', function() {
// History serializes the state, so we don't push the actual route object.
window.history.pushState(currentRoute_.path, '', url);
- setCurrentRoute(route, params);
+ setCurrentRoute(route, params, false);
};
/**
@@ -334,7 +335,7 @@ cr.define('settings', function() {
window.addEventListener('popstate', function(event) {
// On pop state, do not push the state onto the window.history again.
setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC,
- new URLSearchParams(window.location.search));
+ new URLSearchParams(window.location.search), true);
});
return {

Powered by Google App Engine
This is Rietveld 408576698