mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
Fix Android Chromium 85 closes keyboard on selection change
The previous workaround no longer works. You still can't use removeAllRanges (that closes the keyboard too), but we can use the setBaseAndExtent API instead.
This commit is contained in:
parent
c78bd4aac9
commit
19f73d162f
3 changed files with 19 additions and 23 deletions
|
@ -2975,16 +2975,6 @@ proto.setSelection = function ( range ) {
|
||||||
// needing restore on focus.
|
// needing restore on focus.
|
||||||
if ( !this._isFocused ) {
|
if ( !this._isFocused ) {
|
||||||
enableRestoreSelection.call( this );
|
enableRestoreSelection.call( this );
|
||||||
} else if ( isAndroid && !this._restoreSelection ) {
|
|
||||||
// Android closes the keyboard on removeAllRanges() and doesn't
|
|
||||||
// open it again when addRange() is called, sigh.
|
|
||||||
// Since Android doesn't trigger a focus event in setSelection(),
|
|
||||||
// use a blur/focus dance to work around this by letting the
|
|
||||||
// selection be restored on focus.
|
|
||||||
// Need to check for !this._restoreSelection to avoid infinite loop
|
|
||||||
enableRestoreSelection.call( this );
|
|
||||||
this.blur();
|
|
||||||
this.focus();
|
|
||||||
} else {
|
} else {
|
||||||
// iOS bug: if you don't focus the iframe before setting the
|
// iOS bug: if you don't focus the iframe before setting the
|
||||||
// selection, you can end up in a state where you type but the input
|
// selection, you can end up in a state where you type but the input
|
||||||
|
@ -2994,7 +2984,15 @@ proto.setSelection = function ( range ) {
|
||||||
this._win.focus();
|
this._win.focus();
|
||||||
}
|
}
|
||||||
var sel = getWindowSelection( this );
|
var sel = getWindowSelection( this );
|
||||||
if ( sel ) {
|
if ( sel && sel.setBaseAndExtent ) {
|
||||||
|
sel.setBaseAndExtent(
|
||||||
|
range.startContainer,
|
||||||
|
range.startOffset,
|
||||||
|
range.endContainer,
|
||||||
|
range.endOffset,
|
||||||
|
);
|
||||||
|
} else if ( sel ) {
|
||||||
|
// This is just for IE11
|
||||||
sel.removeAllRanges();
|
sel.removeAllRanges();
|
||||||
sel.addRange( range );
|
sel.addRange( range );
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -404,16 +404,6 @@ proto.setSelection = function ( range ) {
|
||||||
// needing restore on focus.
|
// needing restore on focus.
|
||||||
if ( !this._isFocused ) {
|
if ( !this._isFocused ) {
|
||||||
enableRestoreSelection.call( this );
|
enableRestoreSelection.call( this );
|
||||||
} else if ( isAndroid && !this._restoreSelection ) {
|
|
||||||
// Android closes the keyboard on removeAllRanges() and doesn't
|
|
||||||
// open it again when addRange() is called, sigh.
|
|
||||||
// Since Android doesn't trigger a focus event in setSelection(),
|
|
||||||
// use a blur/focus dance to work around this by letting the
|
|
||||||
// selection be restored on focus.
|
|
||||||
// Need to check for !this._restoreSelection to avoid infinite loop
|
|
||||||
enableRestoreSelection.call( this );
|
|
||||||
this.blur();
|
|
||||||
this.focus();
|
|
||||||
} else {
|
} else {
|
||||||
// iOS bug: if you don't focus the iframe before setting the
|
// iOS bug: if you don't focus the iframe before setting the
|
||||||
// selection, you can end up in a state where you type but the input
|
// selection, you can end up in a state where you type but the input
|
||||||
|
@ -423,7 +413,15 @@ proto.setSelection = function ( range ) {
|
||||||
this._win.focus();
|
this._win.focus();
|
||||||
}
|
}
|
||||||
var sel = getWindowSelection( this );
|
var sel = getWindowSelection( this );
|
||||||
if ( sel ) {
|
if ( sel && sel.setBaseAndExtent ) {
|
||||||
|
sel.setBaseAndExtent(
|
||||||
|
range.startContainer,
|
||||||
|
range.startOffset,
|
||||||
|
range.endContainer,
|
||||||
|
range.endOffset,
|
||||||
|
);
|
||||||
|
} else if ( sel ) {
|
||||||
|
// This is just for IE11
|
||||||
sel.removeAllRanges();
|
sel.removeAllRanges();
|
||||||
sel.addRange( range );
|
sel.addRange( range );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue