Skip to content

Commit 7afa822

Browse files
fredckReinmar
authored andcommitted
Avoid double manipulation on the selection because of Firefox bug.
1 parent c335a3f commit 7afa822

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

core/selection.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,17 @@
206206
evt.removeListener();
207207

208208
if ( restoreSel !== 0 ) {
209-
var rng = editor.createRange();
210-
rng.moveToElementEditStart( editable );
211-
rng.select();
209+
var native = editor.getSelection().getNative();
210+
// Do it only if the native selection is at an unwanted
211+
// place (at the very start of the editable). #10119
212+
// IEs<9 won't enter this if (no isCollapsed property on selection instance),
213+
// but this is acceptable since they do a good job in terms of
214+
// default selection positioning.
215+
if ( native.isCollapsed && native.anchorNode == editable.$ ) {
216+
var rng = editor.createRange();
217+
rng.moveToElementEditStart( editable );
218+
rng.select();
219+
}
212220
}
213221
}, null, null, -2 );
214222
}

plugins/elementspath/plugin.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,17 @@
8888

8989

9090
function onClick( elementIndex ) {
91-
editor.focus();
9291
var element = editor._.elementsPath.list[ elementIndex ];
9392
if ( element.equals( editor.editable() ) ) {
9493
var range = editor.createRange();
9594
range.selectNodeContents( element );
9695
range.select();
9796
} else
9897
editor.getSelection().selectElement( element );
98+
99+
// It is important to focus() *after* the above selection
100+
// manipulation, otherwise Firefox will have troubles. #10119
101+
editor.focus();
99102
}
100103

101104
var onClickHanlder = CKEDITOR.tools.addFunction( onClick );

0 commit comments

Comments
 (0)