This repository was archived by the owner on Jun 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,8 @@ export default class FocusTracker {
115115 * @fires blur
116116 */
117117 _blur ( ) {
118+ clearTimeout ( this . _nextEventLoopTimeout ) ;
119+
118120 this . _nextEventLoopTimeout = setTimeout ( ( ) => {
119121 this . focusedElement = null ;
120122 this . isFocused = false ;
Original file line number Diff line number Diff line change @@ -115,6 +115,19 @@ describe( 'FocusTracker', () => {
115115 expect ( focusTracker . isFocused ) . to . true ;
116116 expect ( changeSpy . notCalled ) . to . true ;
117117 } ) ;
118+
119+ // https://github.com/ckeditor/ckeditor5-utils/issues/159
120+ it ( 'should keep `isFocused` synced when multiple blur events are followed by the focus' , ( ) => {
121+ focusTracker . add ( container ) ;
122+ focusTracker . isFocused = true ;
123+
124+ container . dispatchEvent ( new Event ( 'blur' ) ) ;
125+ containerFirstInput . dispatchEvent ( new Event ( 'blur' ) ) ;
126+ containerSecondInput . dispatchEvent ( new Event ( 'focus' ) ) ;
127+ testUtils . sinon . clock . tick ( 0 ) ;
128+
129+ expect ( focusTracker . isFocused ) . to . be . true ;
130+ } ) ;
118131 } ) ;
119132 } ) ;
120133
You can’t perform that action at this time.
0 commit comments