Introduce ArticleTarget#afterSurfaceReady

This method should be called once the surface is visible
and ready to be focused.

Change-Id: I43a1d9cabd59181d2beab8f4a29700d031903c22
This commit is contained in:
Ed Sanders 2021-12-21 18:41:36 +00:00 committed by Bartosz Dziewoński
parent 93df71af77
commit 6c471c5b1e
3 changed files with 21 additions and 8 deletions

View file

@ -483,13 +483,18 @@ ve.init.mw.ArticleTarget.prototype.surfaceReady = function () {
// Parent method
ve.init.mw.ArticleTarget.super.prototype.surfaceReady.apply( this, arguments );
// Do this after window is made scrollable on mobile
// ('surfaceReady' handler in VisualEditorOverlay in MobileFrontend)
this.restoreEditSection();
mw.hook( 've.activationComplete' ).fire();
};
/**
* Runs after the surface has been made ready and visible
*
* Implementing sub-classes must call this method.
*/
ve.init.mw.ArticleTarget.prototype.afterSurfaceReady = function () {
this.restoreEditSection();
};
/**
* @inheritdoc
*/

View file

@ -456,6 +456,8 @@ ve.init.mw.DesktopArticleTarget.prototype.afterActivate = function () {
// (We do this here because toggling 've-active' class above hides it)
this.$editableContent.find( 'style[data-mw-deduplicate^="TemplateStyles:"]' ).prop( 'disabled', true );
this.afterSurfaceReady();
if ( !this.editingTabDialog ) {
if ( this.sectionTitle ) {
this.sectionTitle.focus();

View file

@ -290,10 +290,6 @@ ve.init.mw.MobileArticleTarget.prototype.surfaceReady = function () {
return;
}
// Calls scrollSelectionIntoView so must be called before parent,
// which calls goToHeading. (T225292)
this.adjustContentPadding();
// Deactivate the surface so any initial selection set in surfaceReady
// listeners doesn't cause the keyboard to be shown.
this.getSurface().getView().deactivate( false );
@ -317,6 +313,16 @@ ve.init.mw.MobileArticleTarget.prototype.surfaceReady = function () {
}
};
/**
* @inheritdoc
*/
ve.init.mw.MobileArticleTarget.prototype.afterSurfaceReady = function () {
this.adjustContentPadding();
// Parent method
ve.init.mw.MobileArticleTarget.super.prototype.afterSurfaceReady.apply( this, arguments );
};
/**
* Match the content padding to the toolbar height
*/