Mooeypoo has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/195631

Change subject: Focus the surface after VE is already active
......................................................................

Focus the surface after VE is already active

Move the surface focus() call to be done after VE has loaded, to
make sure that the position of the content editable field is at the
top of the page and not -- as happens in Firefox -- after the read
page contents.

Bug: T90420
Change-Id: If91cea42c083d67b1ee6396402c3f607dde70471
---
M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
1 file changed, 10 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/31/195631/1

diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js 
b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
index 7679519..dc28536 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
@@ -292,6 +292,9 @@
  * @return {jQuery.Promise}
  */
 ve.init.mw.ViewPageTarget.prototype.activate = function () {
+       var surface,
+               pageTarget = this;
+
        if ( !this.active && !this.activating ) {
                ve.track( 'trace.activate.enter' );
                this.activating = true;
@@ -301,6 +304,10 @@
                $( 'html' ).addClass( 've-activating ve-activated' );
                $.when( this.activatingDeferred, this.toolbarSetupDeferred 
).always( function () {
                        $( 'html' ).removeClass( 've-activating' ).addClass( 
've-active' );
+                       // We have to focus the page after hiding the original 
content, otherwise
+                       // in firefox the contentEditable container was below 
the view page, and
+                       // 'focus' scrolled the screen down.
+                       pageTarget.getSurface().getView().focus();
                } );
 
                this.bindHandlers();
@@ -315,7 +322,7 @@
                this.saveScrollPosition();
 
                // Create dummy surface to show toolbar while loading
-               var surface = this.addSurface( [] );
+               surface = this.addSurface( [] );
                surface.disable();
                // setSurface creates dummy toolbar
                this.setSurface( surface );
@@ -529,15 +536,15 @@
        // Update UI
        this.changeDocumentTitle();
 
-       this.getSurface().getView().focus();
-
        this.setupToolbarSaveButton();
        this.attachToolbarSaveButton();
        this.restoreScrollPosition();
        this.restoreEditSection();
        this.setupUnloadHandlers();
        this.maybeShowDialogs();
+
        this.activatingDeferred.resolve();
+
        mw.hook( 've.activationComplete' ).fire();
        ve.track( 'trace.activate.exit' );
 };

-- 
To view, visit https://gerrit.wikimedia.org/r/195631
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If91cea42c083d67b1ee6396402c3f607dde70471
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to