From: Alexander Ebert Date: Mon, 26 Sep 2016 11:03:50 +0000 (+0200) Subject: Improved overlay behavior for iOS X-Git-Tag: 3.0.0_Beta_2~128 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9dd53e9305ee9e320efe859d256d6af92498f8b7;p=GitHub%2FWoltLab%2FWCF.git Improved overlay behavior for iOS --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js index bed77c574d..42b4012d7a 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js @@ -10,12 +10,12 @@ define( [ 'enquire', 'Ajax', 'Core', 'Dictionary', 'Environment', 'Language', 'ObjectMap', 'Dom/ChangeListener', - 'Dom/Traverse', 'Dom/Util', 'Ui/Confirmation', 'Ui/SimpleDropdown' + 'Dom/Traverse', 'Dom/Util', 'Ui/Confirmation', 'Ui/Screen', 'Ui/SimpleDropdown' ], function( enquire, Ajax, Core, Dictionary, Environment, Language, ObjectMap, DomChangeListener, - DomTraverse, DomUtil, UiConfirmation, UiSimpleDropdown + DomTraverse, DomUtil, UiConfirmation, UiScreen, UiSimpleDropdown ) { "use strict"; @@ -227,7 +227,23 @@ define( this._createDialog(id, html, options); } - return _dialogs.get(id); + var data = _dialogs.get(id); + + // iOS breaks `position: fixed` when input elements or `contenteditable` + // are focused, this will freeze the screen and force Safari to scroll + // to the input field + if (Environment.platform() === 'ios') { + UiScreen.scrollDisable(); + + window.setTimeout((function () { + var input = elBySel('input, textarea', data.content); + if (input !== null) { + input.focus(); + } + }).bind(this), 200); + } + + return data; }, /** @@ -557,6 +573,10 @@ define( data = _dialogs.get(_activeDialog); elData(_container, 'close-on-click', (data.backdropCloseOnClick ? 'true' : 'false')); } + + if (Environment.platform() === 'ios') { + UiScreen.scrollEnable(); + } }, /**