Skip to content

Commit

Permalink
Avoid double manipulation on the selection because of Firefox bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
fredck authored and Reinmar committed Feb 26, 2013
1 parent c335a3f commit 7afa822
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 11 additions & 3 deletions core/selection.js
Expand Up @@ -206,9 +206,17 @@
evt.removeListener();

if ( restoreSel !== 0 ) {
var rng = editor.createRange();
rng.moveToElementEditStart( editable );
rng.select();
var native = editor.getSelection().getNative();
// Do it only if the native selection is at an unwanted
// place (at the very start of the editable). #10119
// IEs<9 won't enter this if (no isCollapsed property on selection instance),
// but this is acceptable since they do a good job in terms of
// default selection positioning.
if ( native.isCollapsed && native.anchorNode == editable.$ ) {
var rng = editor.createRange();
rng.moveToElementEditStart( editable );
rng.select();
}
}
}, null, null, -2 );
}
Expand Down
5 changes: 4 additions & 1 deletion plugins/elementspath/plugin.js
Expand Up @@ -88,14 +88,17 @@


function onClick( elementIndex ) {
editor.focus();
var element = editor._.elementsPath.list[ elementIndex ];
if ( element.equals( editor.editable() ) ) {
var range = editor.createRange();
range.selectNodeContents( element );
range.select();
} else
editor.getSelection().selectElement( element );

// It is important to focus() *after* the above selection
// manipulation, otherwise Firefox will have troubles. #10119
editor.focus();
}

var onClickHanlder = CKEDITOR.tools.addFunction( onClick );
Expand Down

0 comments on commit 7afa822

Please sign in to comment.