MDL-45239 editor_atto: On Android do not restore focus in the callbackWrapper

It seems that Android automatically focuses the cursor in the last position
when the content editable region is programatically re-focused.

Whilst this does not cause an issue on it's own, when combined with the
behaviour of the dictionary auto-completion to restore focus on the start
of the word when a word has not yet been finished, this was causing us to
change focus when pressing buttons.
This commit is contained in:
Andrew Nicols
2014-05-22 13:02:26 +08:00
committed by Marina Glancy
parent 2e2a229f58
commit fb7e5c42cd
8 changed files with 21 additions and 9 deletions
@@ -1024,7 +1024,7 @@ EditorSelection.prototype = {
}
// We can't be active if the editor doesn't have focus at the moment.
if (!document.activeElement || document.activeElement !== this.editor) {
if (!document.activeElement || Y.one(document.activeElement) !== this.editor) {
return false;
}
File diff suppressed because one or more lines are too long
@@ -1019,7 +1019,7 @@ EditorSelection.prototype = {
}
// We can't be active if the editor doesn't have focus at the moment.
if (!document.activeElement || document.activeElement !== this.editor) {
if (!document.activeElement || Y.one(document.activeElement) !== this.editor) {
return false;
}
@@ -751,7 +751,11 @@ EditorPluginButtons.prototype = {
return;
}
if (!this.get('host').isActive()) {
if (!(YUI.Env.UA.android || this.get('host').isActive())) {
// We must not focus for Android here, even if the editor is not active because the keyboard auto-completion
// changes the cursor position.
// If we save that change, then when we restore the change later we get put in the wrong place.
// Android is fine to save the selection without the editor being in focus.
this.get('host').focus();
}
File diff suppressed because one or more lines are too long
@@ -749,7 +749,11 @@ EditorPluginButtons.prototype = {
return;
}
if (!this.get('host').isActive()) {
if (!(YUI.Env.UA.android || this.get('host').isActive())) {
// We must not focus for Android here, even if the editor is not active because the keyboard auto-completion
// changes the cursor position.
// If we save that change, then when we restore the change later we get put in the wrong place.
// Android is fine to save the selection without the editor being in focus.
this.get('host').focus();
}
+5 -1
View File
@@ -602,7 +602,11 @@ EditorPluginButtons.prototype = {
return;
}
if (!this.get('host').isActive()) {
if (!(YUI.Env.UA.android || this.get('host').isActive())) {
// We must not focus for Android here, even if the editor is not active because the keyboard auto-completion
// changes the cursor position.
// If we save that change, then when we restore the change later we get put in the wrong place.
// Android is fine to save the selection without the editor being in focus.
this.get('host').focus();
}
+1 -1
View File
@@ -121,7 +121,7 @@ EditorSelection.prototype = {
}
// We can't be active if the editor doesn't have focus at the moment.
if (!document.activeElement || document.activeElement !== this.editor) {
if (!document.activeElement || Y.one(document.activeElement) !== this.editor) {
return false;
}