From f361e286ed1ede700fa80e90ffae2cc80b0fad06 Mon Sep 17 00:00:00 2001 From: Jeremy Pyne Date: Fri, 11 Mar 2016 14:44:21 -0500 Subject: [PATCH 1/2] This minor fix will restore the editors cursor in CoreArea editor boxes when they save the item. There is a check included to prevent this behavior is the server level code changes the file for some reason as then the cursor location could act unpredictably, so instead we just let it reset to the beginning of the file. --- .../umbraco_client/CodeArea/UmbracoEditor.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI/umbraco_client/CodeArea/UmbracoEditor.js b/src/Umbraco.Web.UI/umbraco_client/CodeArea/UmbracoEditor.js index 8f0faf2a28..96ef28f53c 100644 --- a/src/Umbraco.Web.UI/umbraco_client/CodeArea/UmbracoEditor.js +++ b/src/Umbraco.Web.UI/umbraco_client/CodeArea/UmbracoEditor.js @@ -35,9 +35,18 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls.CodeEditor"); this._control.val(code); } else { - //this is a wrapper for CodeMirror + //this is a wrapper for CodeMirror this._editor.focus(); + + var codeChanged = this._editor.getValue() != code; + var cursor = this._editor.doc.getCursor(); + this._editor.setValue(code); + + // Restore cursor position if the server saved code matches. + if (!codeChanged) + this._editor.setCursor(cursor); + this._editor.focus(); } }, From 91da14b0c6cee10b3c2a8787b6bd1e24e2539572 Mon Sep 17 00:00:00 2001 From: Jeremy Pyne Date: Fri, 11 Mar 2016 14:56:55 -0500 Subject: [PATCH 2/2] Second fix for partial views. --- src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js b/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js index b7239f8a0f..c3084e439e 100644 --- a/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js +++ b/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js @@ -174,6 +174,9 @@ } if (args.contents) { UmbEditor.SetCode(args.contents); + } else if (!this.IsSimpleEditor) { + // Restore focuse to text region. SetCode also does this. + UmbEditor._editor.focus(); } UmbClientMgr.mainTree().setActiveTreeType(this._opts.currentTreeType);