Open reply dialog should be executed even if overlay failed

Reject promise if gr-overlay failed to resolve

Bug: Issue 10774
Bug: Issue 12180
Change-Id: I0db37e64245aecc2672999b4de108f308bb0fc11
This commit is contained in:
Tao Zhou
2020-02-03 09:17:03 +01:00
parent 9b020576bf
commit 7b3252693b
2 changed files with 6 additions and 9 deletions

View File

@@ -1260,7 +1260,8 @@
* @param {string=} opt_section
*/
_openReplyDialog(opt_section) {
this.$.replyOverlay.open().then(() => {
this.$.replyOverlay.open().finally(() => {
// the following code should be executed no matter open succeed or not
this._resetReplyOverlayFocusStops();
this.$.replyDialog.open(opt_section);
Polymer.dom.flush();

View File

@@ -63,13 +63,13 @@
}
open(...args) {
return new Promise(resolve => {
return new Promise((resolve, reject) => {
Polymer.IronOverlayBehaviorImpl.open.apply(this, args);
if (this._isMobile()) {
this.fire('fullscreen-overlay-opened');
this._fullScreenOpen = true;
}
this._awaitOpen(resolve);
this._awaitOpen(resolve, reject);
});
}
@@ -96,7 +96,7 @@
* NOTE: (wyatta) Slightly hacky way to listen to the overlay actually
* opening. Eventually replace with a direct way to listen to the overlay.
*/
_awaitOpen(fn) {
_awaitOpen(fn, reject) {
let iters = 0;
const step = () => {
this.async(() => {
@@ -105,11 +105,7 @@
} else if (iters++ < AWAIT_MAX_ITERS) {
step.call(this);
} else {
// TODO(crbug.com/gerrit/10774): Once this is confirmed as the root
// cause of the bug, fix it by either making sure to resolve the fn
// function or find a better way to listen on the overlay being
// shown.
console.warn('gr-overlay _awaitOpen failed to resolve');
reject(new Error('gr-overlay _awaitOpen failed to resolve'));
}
}, AWAIT_STEP);
};