Skip to content

Commit

Permalink
MDL-45239 editor_atto: The editor cannot be active if it is not the a…
Browse files Browse the repository at this point in the history
…ctive element

FireFox thinks that you can have an active selection on an element which
currently does not have focus. How this can be the case is a mystery.

Conflicts:
	lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js
  • Loading branch information
andrewnicols authored and marinaglancy committed May 19, 2014
1 parent 17f253f commit 1ce0436
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
Expand Up @@ -1023,6 +1023,11 @@ EditorSelection.prototype = {
return false;
}

// We can't be active if the editor doesn't have focus at the moment.
if (!document.activeElement || document.activeElement !== this.editor) {
return false;
}

// Check whether the range intersects the editor selection.
range.selectNode(this.editor.getDOMNode());
return range.intersectsRange(selection.getRangeAt(0));
Expand Down Expand Up @@ -1051,9 +1056,7 @@ EditorSelection.prototype = {
* @method saveSelection
*/
saveSelection: function() {
if (this.isActive()) {
this._selections = this.getSelection();
}
this._selections = this.getSelection();
},

/**
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -1018,6 +1018,11 @@ EditorSelection.prototype = {
return false;
}

// We can't be active if the editor doesn't have focus at the moment.
if (!document.activeElement || document.activeElement !== this.editor) {
return false;
}

// Check whether the range intersects the editor selection.
range.selectNode(this.editor.getDOMNode());
return range.intersectsRange(selection.getRangeAt(0));
Expand Down Expand Up @@ -1046,9 +1051,7 @@ EditorSelection.prototype = {
* @method saveSelection
*/
saveSelection: function() {
if (this.isActive()) {
this._selections = this.getSelection();
}
this._selections = this.getSelection();
},

/**
Expand Down
9 changes: 6 additions & 3 deletions lib/editor/atto/yui/src/editor/js/selection.js
Expand Up @@ -120,6 +120,11 @@ EditorSelection.prototype = {
return false;
}

// We can't be active if the editor doesn't have focus at the moment.
if (!document.activeElement || document.activeElement !== this.editor) {
return false;
}

// Check whether the range intersects the editor selection.
range.selectNode(this.editor.getDOMNode());
return range.intersectsRange(selection.getRangeAt(0));
Expand Down Expand Up @@ -148,9 +153,7 @@ EditorSelection.prototype = {
* @method saveSelection
*/
saveSelection: function() {
if (this.isActive()) {
this._selections = this.getSelection();
}
this._selections = this.getSelection();
},

/**
Expand Down

0 comments on commit 1ce0436

Please sign in to comment.