Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Added delay to selection observer making the event asyn also on Chrom…
Browse files Browse the repository at this point in the history
…e for Android.
  • Loading branch information
szymonkups committed Jan 10, 2018
1 parent 9664b5d commit d5894f5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/view/observer/selectionobserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @module engine/view/observer/selectionobserver
*/

/* global setInterval, clearInterval */
/* global setInterval, clearInterval, setTimeout */

import Observer from './observer';
import MutationObserver from './mutationobserver';
Expand Down Expand Up @@ -108,7 +108,11 @@ export default class SelectionObserver extends Observer {
}

this.listenTo( domDocument, 'selectionchange', () => {
this._handleSelectionChange( domDocument );
// Setting short timeout to make selectionchange always async.
// Android Chrome fires selectionchange event before the mutations.
setTimeout( () => {
this._handleSelectionChange( domDocument );
}, 1 );
} );

this._documents.add( domDocument );
Expand Down

0 comments on commit d5894f5

Please sign in to comment.