From 49ffef5a0f15ef7b8f694cb050ac6d628bfd79a8 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Wed, 16 Jul 2014 16:45:49 -0700 Subject: [PATCH] Close the save dialog on teardown only, not on save Closing a dialog with specific data means closing it again with potentially different data, while the dialog is already closing, means someone wins and someone looses. Silently failing in this case is bad, because if the first close call was a cancel, producing no side effects, but the second close call would have produced some side effect, the side effect would never occur. The problem here really was that the save dialog needs to be closed before we can destroy the surface so we can uphold the assumption that hold and teardown processes are operating on an attached DOM. The solution is to automatically close the save dialog on teardown, rather than on save. Since save triggers teardown, this has and identical user experience. Bug: 68048 Change-Id: I669448739f168737d4eddd6496189a819ce894b1 --- modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js index 44f457f90d..3598872fde 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js @@ -470,7 +470,6 @@ ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, categoriesHtml, ne } ); this.revid = newid; } - this.saveDialog.close(); this.saveDialog.reset(); this.replacePageContent( html, categoriesHtml, isRedirect, displayTitle ); this.setupSectionEditLinks(); @@ -1090,9 +1089,11 @@ ve.init.mw.ViewPageTarget.prototype.tearDownSurface = function () { if ( this.surface.mwTocWidget ) { this.surface.mwTocWidget.teardown(); } + if ( this.saveDialog ) { - // If we got as far as setting up the save dialog, tear it down + // If the save dialog is still open (from saving) close it promises.push( this.saveDialog.close() ); + // Release the reference this.saveDialog = null; }