core/modules/edit/js/views/AppView.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/core/modules/edit/js/views/AppView.js b/core/modules/edit/js/views/AppView.js index 68bbdad..1b1c5c2 100644 --- a/core/modules/edit/js/views/AppView.js +++ b/core/modules/edit/js/views/AppView.js @@ -3,10 +3,12 @@ "use strict"; // Indicates whether the page should be reloaded after in-place editing has -// shut down. A page reload is necessary to re-instate the original values of -// editing fields if the in-place editing has been canceled and the changes -// were not saved. -var reload; +// shut down. A page reload is necessary to re-instate the original HTML of the +// edited fields if in-place editing has been canceled and one or more of the +// entity's fields were saved to TempStore: one of them may have been changed to +// the empty value and hence may have been rerendered as the empty string, which +// makes it impossible for Edit to know where to restore the original HTML. +var reload = false; /** * @@ -59,6 +61,7 @@ Drupal.edit.AppView = Backbone.View.extend({ var entityToolbarView; switch (state) { case 'launching': + reload = false; // First, create an entity toolbar view. entityToolbarView = new Drupal.edit.EntityToolbarView({ model: entityModel, @@ -89,11 +92,10 @@ Drupal.edit.AppView = Backbone.View.extend({ entityModel.get('fields').each(function (fieldModel) { app.teardownEditor(fieldModel); }); - // A page reload is necessary to re-instate the original values of - // editing fields if the in-place editing has been canceled and the changes - // were not saved. + // A page reload may be necessary to re-instate the original HTML of the + // edited fields. if (reload) { - reload = null; + reload = false; location.reload(); } break; @@ -360,8 +362,11 @@ Drupal.edit.AppView = Backbone.View.extend({ fieldModel.set('state', 'candidate', {confirmed : true}); }); // Editing has been canceled and the changes will not be saved. Mark - // the page for reload after in-place editing has shut down. - reload = true; + // the page for reload after in-place editing has shut down, if and + // only if >=1 field was changed and saved to TempStore. + if (activeEntity.get('inTempStore')) { + reload = true; + } } } }); @@ -398,7 +403,7 @@ Drupal.edit.AppView = Backbone.View.extend({ else if (this.model.get('activeEditor') === fieldModel && to === 'candidate') { // Discarded if it transitions from a changed state to 'candidate'. if (from === 'changed' || from === 'invalid') { -// fieldModel.editorView.revert(); + fieldModel.editorView.revert(); } this.model.set('activeEditor', null); }