From e6b91ced43c3084515a5fdde2bf48ed5fef6f6b7 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Mon, 21 Sep 2020 20:52:47 +0100 Subject: [PATCH] Collapse advanced drawer when clearing Bug: T263061 Change-Id: Ibcd95ce1c86548962b9b7ff7b62bd0d127f53b76 --- modules/dt.ui.ReplyWidget.js | 8 ++++++++ modules/dt.ui.ReplyWidgetVisual.js | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/dt.ui.ReplyWidget.js b/modules/dt.ui.ReplyWidget.js index 8cf7bc84f..5e53cd444 100644 --- a/modules/dt.ui.ReplyWidget.js +++ b/modules/dt.ui.ReplyWidget.js @@ -243,11 +243,19 @@ ReplyWidget.prototype.isEmpty = null; ReplyWidget.prototype.getMode = null; +/** + * Restore the widget to its original state + * + * Clear any widget values, reset UI states, and clear + * any auto-save values. + */ ReplyWidget.prototype.clear = function () { if ( this.errorMessage ) { this.errorMessage.$element.remove(); } this.$preview.empty(); + this.toggleAdvanced( false ); + this.storage.remove( this.storagePrefix + '/mode' ); this.storage.remove( this.storagePrefix + '/saveable' ); this.storage.remove( this.storagePrefix + '/summary' ); diff --git a/modules/dt.ui.ReplyWidgetVisual.js b/modules/dt.ui.ReplyWidgetVisual.js index 62910f270..605830040 100644 --- a/modules/dt.ui.ReplyWidgetVisual.js +++ b/modules/dt.ui.ReplyWidgetVisual.js @@ -126,8 +126,11 @@ ReplyWidgetVisual.prototype.teardown = function () { ReplyWidgetVisual.prototype.focus = function () { var targetWidget = this.replyBodyWidget; setTimeout( function () { - targetWidget.getSurface().getModel().selectLastContentOffset(); - targetWidget.focus(); + // Check surface still exists after timeout + if ( targetWidget.getSurface() ) { + targetWidget.getSurface().getModel().selectLastContentOffset(); + targetWidget.focus(); + } } ); return this;