Fix Page Editor textarea always being focused after saving/reloading

This commit is contained in:
Giuseppe Criscione 2018-09-13 16:05:46 +02:00
parent 98e5fe7923
commit 96466eece4
3 changed files with 11 additions and 3 deletions

View File

@ -193,7 +193,11 @@ Formwork.Editor = function(id) {
function retainCursorPosition() {
var data = [location.pathname, textarea.scrollTop, textarea.selectionEnd].join('#');
window.sessionStorage.setItem('formworkEditorCursorPosition', data);
if ($(textarea).is(':focus')) {
window.sessionStorage.setItem('formworkEditorCursorPosition', data);
} else {
window.sessionStorage.removeItem('formworkEditorCursorPosition');
}
}
function restoreCursorPosition() {

File diff suppressed because one or more lines are too long

View File

@ -98,7 +98,11 @@ Formwork.Editor = function(id) {
function retainCursorPosition() {
var data = [location.pathname, textarea.scrollTop, textarea.selectionEnd].join('#');
window.sessionStorage.setItem('formworkEditorCursorPosition', data);
if ($(textarea).is(':focus')) {
window.sessionStorage.setItem('formworkEditorCursorPosition', data);
} else {
window.sessionStorage.removeItem('formworkEditorCursorPosition');
}
}
function restoreCursorPosition() {