diff --git a/CHANGES.md b/CHANGES.md index 4a1554c1974..4533198ad7c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Fixed Issues: * [#12506](http://dev.ckeditor.com/ticket/12506): [Safari] Fixed: Can't paste into inline editor if page has `user-select: none` style. Thanks to [shaohua](https://github.com/shaohua)! * [#12489](http://dev.ckeditor.com/ticket/12423) and [#12491](http://dev.ckeditor.com/ticket/12423): Fixed: Various issues related to restoring selection after making operations on filler char. See the [fixed cases](http://dev.ckeditor.com/ticket/12491#comment:4). +* [#11647](http://dev.ckeditor.com/ticket/11647): Fixed: The [`editor.blur`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-blur) event is not fired on first blur after initializing the inline editor on already focused element. ## CKEditor 4.4.5 diff --git a/core/editable.js b/core/editable.js index 787f69f9a60..50941bf855b 100644 --- a/core/editable.js +++ b/core/editable.js @@ -575,8 +575,8 @@ this.hasFocus = true; // Pending until this editable has attached. editor.once( 'contentDom', function() { - editor.focusManager.focus(); - } ); + editor.focusManager.focus( this ); + }, this ); } // Apply tab index on demand, with original direction saved. diff --git a/tests/core/focusManager/editor.js b/tests/core/focusManager/editor.js index 3846f0a6bd3..53d08487ddd 100644 --- a/tests/core/focusManager/editor.js +++ b/tests/core/focusManager/editor.js @@ -54,6 +54,41 @@ bender.test( var ed = this.editor, bot = this.editorBot; bot.execCommand( 'toolbarFocus' ); this.assertFocus(); + }, + + // #11647 + 'test inheriting the initial focus': function() { + var el = CKEDITOR.document.createElement( 'div' ); + CKEDITOR.document.getBody().append( el ); + el.setAttribute( 'contenteditable', true ); + el.focus(); + + var editor = CKEDITOR.inline( el ), + focusWasFired = 0; + + editor.on( 'focus', function() { + focusWasFired += 1; + } ); + + editor.on( 'instanceReady', function() { + resume( function() { + assert.isTrue( editor.focusManager.hasFocus, 'hasFocus after init' ); + assert.areSame( editor.editable(), editor.focusManager.currentActive, 'currentActive after init' ); + assert.areSame( 1, focusWasFired, 'focus event was fired once' ); + + editor.on( 'blur', function() { + resume( function() { + assert.isFalse( editor.focusManager.hasFocus, 'hasFocus after destroy' ); + editor.destroy(); + } ); + } ); + + CKEDITOR.document.getById( 'focusable' ).focus(); + wait(); + } ); + } ); + + wait(); } } ); \ No newline at end of file