Skip to content

Commit

Permalink
[FIX] util/Mobile: set correct viewport for iPad with "request deskto…
Browse files Browse the repository at this point in the history
…p website"

- "maximum-scale=1.0, user-scalable=no" is still needed for disable
  the auto zoom for iPad with "request desktop website" which isn't
  recognized as iOS device anymore but as a Macintosh with touch
  enabled.

BCP: 002075129400005790312023
Change-Id: Ia5138492976a7d43b8f0c3f2fd745e7fcd0c804a
  • Loading branch information
stopcoder committed Jul 26, 2023
1 parent a1c4878 commit 96a1d29
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/sap.ui.core/src/sap/ui/util/Mobile.js
Expand Up @@ -106,6 +106,8 @@ sap.ui.define(['sap/ui/Device', 'sap/base/Log', 'sap/base/util/extend', 'sap/ui/
mobileWebAppCapable: "default"
}, options);

var bAppleMobileDevice = Device.os.ios || (Device.os.macintosh && Device.browser.mobile);

// en-/disable automatic link generation for phone numbers
if (options.preventPhoneNumberDetection) {
// iOS specific meta tag
Expand All @@ -127,15 +129,17 @@ sap.ui.define(['sap/ui/Device', 'sap/base/Log', 'sap/base/util/extend', 'sap/ui/
// UI) and auto zoom (browser zooms in the UI automatically under some circumtances, for example when an
// input gets the focus and the font-size of the input is less than 16px on iOS) functionalities on the
// mobile platform, but there's some difference between the mobile platforms:
// * iOS: This does not disable manual zoom in Safari and it only disables the auto zoom function. In
// Chrome browser on iOS, it does disable the manual zoom but since Chrome on iOS isn't in the support
// matrix, we can ignore this.
// * Apple mobile device: This does not disable manual zoom in Safari and it only disables the auto
// zoom function. In Chrome browser on iOS, it does disable the manual zoom but since Chrome on iOS
// isn't in the support matrix, we can ignore this. The "Request Desktop Website" is turned on by
// default on iPad, therefore we need to check the (macintosh + touch) combination to detect the iPad
// with "Request Desktop Website" turned on to disable the auto zoom.
// * other mobile platform: it does disable the manual zoom option but there's no auto zoom function.
// So we need to remove the maximum-scale=1.0:
// So we need to remove the maximum-scale=1.0:
//
// Therefore we need to add the additional settings (maximum-scale and user-scalable) only for iOS
// platform
if (Device.os.ios) {
if (bAppleMobileDevice) {
sMeta += ", maximum-scale=1.0, user-scalable=no";
}

Expand All @@ -156,7 +160,7 @@ sap.ui.define(['sap/ui/Device', 'sap/base/Log', 'sap/base/util/extend', 'sap/ui/
});
}

if (options.preventScroll && (Device.os.ios || (Device.os.mac && Device.browser.mobile))) {
if (options.preventScroll && bAppleMobileDevice) {
_ready().then(function() {
document.documentElement.style.position = "fixed";
document.documentElement.style.overflow = "hidden";
Expand Down

0 comments on commit 96a1d29

Please sign in to comment.