From 374fb74a0b31d7c9acf3d7c754749c72dc0e70d0 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 10 Oct 2016 12:34:13 +0200 Subject: [PATCH] Fixed search bar behavior on iOS Focusing a text input turns `position: fixed` into `position: absolute` on iOS. Fixes #2111 --- .../files/js/WoltLabSuite/Core/Ui/Mobile.js | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Mobile.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Mobile.js index 6c5f7c3cb3..e8a7be8819 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Mobile.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Mobile.js @@ -119,17 +119,35 @@ define( var _searchBar = elById('pageHeaderSearch'); var _searchInput = elById('pageHeaderSearchInput'); + var scrollTop = null; + EventHandler.add('com.woltlab.wcf.MainMenuMobile', 'more', function(data) { if (data.identifier === 'com.woltlab.wcf.search') { + data.handler.close(true); + + if (Environment.platform() === 'ios') { + scrollTop = document.body.scrollTop; + UiScreen.scrollDisable(); + } + _searchBar.style.setProperty('top', elById('pageHeader').offsetHeight + 'px', ''); _searchBar.classList.add('open'); _searchInput.focus(); - data.handler.close(true); + if (Environment.platform() === 'ios') { + document.body.scrollTop = 0; + } } }); - _main.addEventListener(WCF_CLICK_EVENT, function() { _searchBar.classList.remove('open'); }); + _main.addEventListener(WCF_CLICK_EVENT, function() { + _searchBar.classList.remove('open'); + + if (Environment.platform() === 'ios') { + UiScreen.scrollEnable(); + document.body.scrollTop = scrollTop; + } + }); }, _initButtonGroupNavigation: function() { -- 2.20.1