From 859d85257b10e40e04a4acad44b0b547a3809ed5 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 29 Jul 2014 14:58:24 -0700 Subject: [PATCH] Delay scrollToHeading() until after the selection is rerendered Otherwise either the focusing of the surface or the resetting of the selection seems to cause the viewport to scroll back up on mobile. Change-Id: Ie3b104e04800d2753f99739f877c76e334965fc1 --- modules/ve-mw/init/ve.init.mw.Target.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index 9404cbd8eb..9b0c6780a6 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -1434,6 +1434,7 @@ ve.init.mw.Target.prototype.startSanityCheck = function () { ve.init.mw.Target.prototype.restoreEditSection = function () { if ( this.section !== undefined && this.section > 0 ) { var offset, offsetNode, nextNode, + target = this, surfaceView = this.surface.getView(), surfaceModel = surfaceView.getModel(), $documentNode = surfaceView.getDocument().getDocumentNode().$element, @@ -1465,9 +1466,8 @@ ve.init.mw.Target.prototype.restoreEditSection = function () { // the model selection, otherwise it will get reset this.surface.getView().once( 'focus', function () { surfaceModel.setSelection( new ve.Range( offset ) ); + target.scrollToHeading( headingNode ); } ); - // Scroll to heading: - this.scrollToHeading( headingNode ); } this.section = undefined;