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 11:55:00 +08:00
parent 37d39fe348
commit 2c549f7802
8 changed files with 21 additions and 9 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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();
}

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();
}

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;
}