Skip to content

Commit 1794e56

Browse files
committed
Merge branch 't/11647'
2 parents af4a784 + e43777f commit 1794e56

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Fixed Issues:
1111

1212
* [#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)!
1313
* [#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).
14+
* [#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.
1415

1516
## CKEditor 4.4.5
1617

core/editable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@
575575
this.hasFocus = true;
576576
// Pending until this editable has attached.
577577
editor.once( 'contentDom', function() {
578-
editor.focusManager.focus();
579-
} );
578+
editor.focusManager.focus( this );
579+
}, this );
580580
}
581581

582582
// Apply tab index on demand, with original direction saved.

tests/core/focusManager/editor.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,41 @@ bender.test(
5454
var ed = this.editor, bot = this.editorBot;
5555
bot.execCommand( 'toolbarFocus' );
5656
this.assertFocus();
57+
},
58+
59+
// #11647
60+
'test inheriting the initial focus': function() {
61+
var el = CKEDITOR.document.createElement( 'div' );
62+
CKEDITOR.document.getBody().append( el );
63+
el.setAttribute( 'contenteditable', true );
64+
el.focus();
65+
66+
var editor = CKEDITOR.inline( el ),
67+
focusWasFired = 0;
68+
69+
editor.on( 'focus', function() {
70+
focusWasFired += 1;
71+
} );
72+
73+
editor.on( 'instanceReady', function() {
74+
resume( function() {
75+
assert.isTrue( editor.focusManager.hasFocus, 'hasFocus after init' );
76+
assert.areSame( editor.editable(), editor.focusManager.currentActive, 'currentActive after init' );
77+
assert.areSame( 1, focusWasFired, 'focus event was fired once' );
78+
79+
editor.on( 'blur', function() {
80+
resume( function() {
81+
assert.isFalse( editor.focusManager.hasFocus, 'hasFocus after destroy' );
82+
editor.destroy();
83+
} );
84+
} );
85+
86+
CKEDITOR.document.getById( 'focusable' ).focus();
87+
wait();
88+
} );
89+
} );
90+
91+
wait();
5792
}
5893

5994
} );

0 commit comments

Comments
 (0)