mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
Prevent scroll move to top when focus method invoked
In webkit, if contenteditable element focus method have been invoked when another input element has focus, contenteditable scroll to top automatically so we need scroll it back
This commit is contained in:
parent
25ff83455e
commit
cbc959067a
1 changed files with 18 additions and 0 deletions
|
@ -624,8 +624,16 @@ proto._updatePathOnEvent = function () {
|
|||
// --- Focus ---
|
||||
|
||||
proto.focus = function () {
|
||||
var scrollTop = this.scrollTop();
|
||||
|
||||
this._root.focus();
|
||||
|
||||
// In webkit, if contenteditable element focus method have been invoked when another input element has focus,
|
||||
// contenteditable scroll to top automatically so we need scroll it back
|
||||
if (scrollTop !== this.scrollTop()) {
|
||||
this.scrollTop(scrollTop);
|
||||
}
|
||||
|
||||
if ( isIE ) {
|
||||
this.fireEvent( 'focus' );
|
||||
}
|
||||
|
@ -643,6 +651,16 @@ proto.blur = function () {
|
|||
return this;
|
||||
};
|
||||
|
||||
// --- scrollTop ---
|
||||
|
||||
proto.scrollTop = function(value) {
|
||||
if (value) {
|
||||
this._root.scrollTop = value;
|
||||
}
|
||||
|
||||
return this._root.scrollTop;
|
||||
}
|
||||
|
||||
// --- Bookmarking ---
|
||||
|
||||
var startSelectionId = 'squire-selection-start';
|
||||
|
|
Loading…
Reference in a new issue