Commit fd4cbf5f authored by dpapad's avatar dpapad Committed by Commit Bot

Settings: Fix race condition in MainPageBehavior.

The race condition manifested when transitioning from a subpage to
another sibling subpage, and caused the showing-main-page event to
erroneously be fired after the subpage-expand event.

Bug: 928082
Change-Id: If66e0d0e62cda2d1310dddc067429ca6f7133368
Reviewed-on: https://chromium-review.googlesource.com/c/1459589
Commit-Queue: Nicolas Ouellet-Payeur <nicolaso@chromium.org>
Auto-Submit: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarNicolas Ouellet-Payeur <nicolaso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630322}
parent 42987362
......@@ -202,17 +202,21 @@ cr.define('settings', function() {
/**
* @param {!settings.Route} oldRoute
* @return {!Promise<void>}
* @private
*/
enterMainPage_: function(oldRoute) {
const oldSection = this.getSection(oldRoute.section);
oldSection.classList.remove('expanded');
this.classList.remove('showing-subpage');
requestAnimationFrame(() => {
if (settings.lastRouteChangeWasPopstate()) {
this.scroller.scrollTop = this.lastScrollTop_;
}
this.fire('showing-main-page');
return new Promise((res, rej) => {
requestAnimationFrame(() => {
if (settings.lastRouteChangeWasPopstate()) {
this.scroller.scrollTop = this.lastScrollTop_;
}
this.fire('showing-main-page');
res();
});
});
},
......@@ -318,8 +322,9 @@ cr.define('settings', function() {
// different sections, but are linked to each other. For example
// /storage and /accounts (in ChromeOS).
if (!oldRoute.contains(newRoute) && !newRoute.contains(oldRoute)) {
this.enterMainPage_(oldRoute);
this.enterSubpage_(newRoute);
this.enterMainPage_(oldRoute).then(() => {
this.enterSubpage_(newRoute);
});
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment