0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2025-01-03 05:00:13 -05:00

Don't disable restore selection on input

The only time we don't want to restore selection is if the user explicitly
changes it, by clicking/touching a specific cursor point.

Fixes formatting commands in IE11, where the mutation event first between
calling editor.focus() and the focus event actually firing, rather than
after the focus event as in other browsers.
This commit is contained in:
Neil Jenkins 2016-06-27 12:05:40 +10:00
parent f060dbf978
commit 267085e8c1
3 changed files with 7 additions and 11 deletions

View file

@ -2352,13 +2352,11 @@ function Squire ( root, config ) {
this.addEventListener( 'keyup', this._keyUpDetectChange );
}
// On blur, restore focus except if there is any change to the content, or
// the user taps or clicks to focus a specific point. Can't actually use
// click event because focus happens before click, so use
// mousedown/touchstart
// On blur, restore focus except if the user taps or clicks to focus a
// specific point. Can't actually use click event because focus happens
// before click, so use mousedown/touchstart
this._restoreSelection = false;
this.addEventListener( 'blur', enableRestoreSelection );
this.addEventListener( 'input', disableRestoreSelection );
this.addEventListener( 'mousedown', disableRestoreSelection );
this.addEventListener( 'touchstart', disableRestoreSelection );
this.addEventListener( 'focus', restoreSelection );

File diff suppressed because one or more lines are too long

View file

@ -84,13 +84,11 @@ function Squire ( root, config ) {
this.addEventListener( 'keyup', this._keyUpDetectChange );
}
// On blur, restore focus except if there is any change to the content, or
// the user taps or clicks to focus a specific point. Can't actually use
// click event because focus happens before click, so use
// mousedown/touchstart
// On blur, restore focus except if the user taps or clicks to focus a
// specific point. Can't actually use click event because focus happens
// before click, so use mousedown/touchstart
this._restoreSelection = false;
this.addEventListener( 'blur', enableRestoreSelection );
this.addEventListener( 'input', disableRestoreSelection );
this.addEventListener( 'mousedown', disableRestoreSelection );
this.addEventListener( 'touchstart', disableRestoreSelection );
this.addEventListener( 'focus', restoreSelection );