From d10dd4ded070347c136557003ffad5c8f55c5ab1 Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Fri, 26 Aug 2022 15:30:57 +0200 Subject: [PATCH] Don't focus template input fields (and open keyboard) on mobile On mobile, tapping anything in the sidebar should only scroll the corresponding element into view, but not focus the input field. The reasoning is that an on-screen keyboard should only pop up when the input field is actually tapped. By the way, the "jump" issue in T312768 was because of the same reason. In that case an onFocus happens before we have a chance to scroll. Unfortunately there is no way to reverse the execution order of these. Which is why we disabled the animation there. Bug: T289043 Change-Id: I1c18802b8ff776fa8d9c17e3df8020354690d29f --- .../ve.ui.MWTwoPaneTransclusionDialogLayout.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js b/modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js index bf24f335b7..b506b52f04 100644 --- a/modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js +++ b/modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js @@ -140,14 +140,19 @@ ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.focusPart = function ( pageNam */ ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.onSidebarItemSelected = function ( pageName, soft ) { this.setPage( pageName ); - if ( !soft ) { - this.focus(); - } var page = this.pages[ pageName ]; if ( page ) { + // Warning, scrolling must be done before focussing. The browser will trigger a conflicting + // scroll when the focussed element is out of view. page.scrollElementIntoView( { alignToTop: true, padding: { top: 20 } } ); } + + // We assume "mobile" means "touch device with on-screen keyboard". That should only open when + // tapping the input field, not when navigating in the sidebar. + if ( !soft && !OO.ui.isMobile() ) { + this.focus(); + } }; /**