Visualforce page automatically scrolls to top when user taps on a page element in Salesforce1 on iOS devices

Visualforce page automatically scrolls to top when user taps on a page element in Salesforce1 on iOS devices

Mobile

Last updated 2017-04-05 ·Reference W-2187727 ·Reported By 149 users

No Fix

Summary
This issue affects the Salesforce1 for iOS hybrid app and the Salesforce1 browser app in iOS Safari.

When a user is using a Visualforce page and they tap on a picklist or multi-picklist field then the Visual Force page scrolls to the top and the user loses focus on the area of the page they were in.

Repro
1) Open a Visualforce page in Salesforce1 that has a height greater than the screen height.

2) Tap a picklist/multi picklist field near the bottom of the page (other elements may also be affected depending on the implementation).

3) Notice the page automatically scroll to the top.

Workaround
The following two workarounds are not guaranteed to work for every implementation, not supported by Salesforce, and you should use them at your own risk.

1) Add the following JavaScript to your page:

<script>
(function(){try{var a=navigator.userAgent;
if((a.indexOf('Salesforce')!=-1)&&(a.indexOf('iPhone')!=-1||a.indexOf('iPad')!=-1)&&(a.indexOf('OS/8')!=-1||a.indexOf('OS 8')!=-1)&&(a.indexOf('Safari')==-1)){
var s=document.createElement('style');
s.innerHTML="html,html body{overflow: auto;-webkit-overflow-scrolling:touch;}body{position:absolute;left:0;right:0;top:0;bottom:0;}";
document.getElementsByTagName('head')[0].appendChild(s);}}catch(e){}})();
</script>

2) Add the following JavaScript to your page:

<script>
var ua=navigator.userAgent;
if((ua.indexOf('Salesforce')!=-1)&&(ua.indexOf('iPhone')!=-1||ua.indexOf('iPad')!=-1)&&(ua.indexOf('OS/8')!=-1||ua.indexOf('OS 8')!=-1)&&(ua.indexOf('Safari')==-1)){
function IOS_SCROLL_BOOTSTRAP() {
var children = Array.prototype.slice.call(document.body.children),
placeholder = document.createElement('section'),
fragment = document.createDocumentFragment(),
styles,
width,
height;
children.forEach(function(c){fragment.appendChild(c);});
placeholder.appendChild(fragment);
styles = [
'width:100%;',
'height:', (window.screen.height - 42), 'px;',
'position: absolute; overflow: auto; -webkit-overflow-scrolling: touch'
].join('');
placeholder.style.cssText = styles;
document.body.appendChild(placeholder);
}
window.addEventListener('load', function (e) {
IOS_SCROLL_BOOTSTRAP();
});
}
</script>

Reported By (149)

Tetsuro Iwai David Torres Mauricio del Rio David Vo Josiah Lee MII Dispatch Tony Montemorano Ashley McIntyre Carmelo Andronaco Max Stein Dave Vacanti Shankar Dupade William Velazquez Pradeep Kumar Kevin Yamazaki Hoang Vinh Long Andrew Corr Bryan Anderson Lawrence Tijerina Jonathan Green Chirag Mehta Michael Rambus Jason Giamattei Jeffrey Kranz APIG - Sys Admin - APIG Mark Baird Tom Vieira Roman Carvajal Martin Borthiry Ben Merven Miguel Fermin Ronak Shah Sushil Kumar 友美 吉岡 Kyle Heddon Dieffrei Quadros Gaurav Kheterpal NIVEDITA RATHOD Adil Delawalla Aleksey Shutov Fred Hays Kuldeep Apradh Yannick van Eldik Terry Smith Elliott Thomas Doug Ayers Karen Romero Nick Sharp Sripriya Kongot Nagesh Earanti Handie Mobil Christian Møller Andersen Øyvind Rotnes Jonas Korssjøen Henrik Bjerke Carl Huseby Fosli Rune Waage Espen Torås Developer Masaki Kubomura Ben Nguyen Vidar Fjellestad Vidar Fjellestad Govardhan Muralidhar Phil Rymek Jason Ernst Ameya Dhuri (Swiss Re) András Vadász Terry Nong Lorenzo Velazquez-Carlos Axella Stern Eva DeLorio Tom Nepa Murugadoss Balasubramanian Ashok Somisetty Nikhil S Jan Vandevelde Eric Miller Ryan Ellis Bethany Kemp Pierrick Gosset Johan Yu Nagendra singh bhadoriya Bindu Dubey Christophe Soulet Mike Pedersen Nithin George Koshy Clay Johnson Les Ponneri Paul Kissick James Richardson Thomas De Lépinay Mélanie Texereau System Admin Vivek Jain RG DeGuzman Shane McLaughlin Sean Upton Davey Winkel abcd efg Gerry Ryan Ivano Harris Brian Clift Pavel Zhila Matt Lacey Jonathan Riehm Ben Whatton Leonardo Silva Gordon Bockus Elie Buff 一樹 中嶋 Sebastian Alzate Andrew Taylor Hiroshi Yoshita trung khiem John Mallinder Viki Baarathi Denis Lacoste Matt Bostrom Gianluca Calcagni Nick Bjerken aswin vijayan Sharon Wilson Sripriya Kongot Zoran Zunko Uriah McKinney Mike Martin Michael Dapice Alec Davis Phil Maier Cindy Schmidt Jeff Barnett Craig Johnson giribabu Amanpreet Sidhu Richard Blake ashok br Prashant Karadi Preston Landers Julien Gaïotto Groupe Cassous Thibault Weber Didier Huguet Mark Wheeler Paul Allen Keir Bowden Carolina Ruiz Patrick Hicks Marc Thomas

Is it Fixed?

AP0 AP3 AP4 AP5 AP6 AP7 AP8 AP9 AP14 AP15 AP20 AP21 AP22 AP28 CS1 CS2 CS3 CS4 CS5 CS6 CS7 CS8 CS9 CS10 CS109 CS108 CS107 CS106 CS105 CS102 CS101 CS100 CS115 CS110 CS11 CS116 CS12 CS137 CS138 CS13 CS14 CS15 CS152 CS151 CS16 CS17 CS18 CS19 CS20 CS21 CS22 CS23 CS24 CS25 CS26 CS27 CS28 CS29 CS30 CS31 CS32 CS33 CS34 CS35 CS36 CS37 CS40 CS41 CS42 CS43 CS44 CS45 CS47 CS50 CS51 CS52 CS53 CS54 CS57 CS58 CS59 CS60 CS61 CS62 CS63 CS64 CS65 CS66 CS67 CS68 CS69 CS70 CS71 CS72 CS73 CS74 CS75 CS76 CS77 CS78 CS79 CS80 CS81 CS82 CS83 CS84 CS85 CS86 CS87 CS88 CS89 CS90 CS91 CS92 CS93 CS94 CS95 CS96 CS97 CS98 CS99 EU7 EU8 EU9 EU10 EU12 EU13 EU14 EU15 EU16 EU17 EU18 EU19 EU25 EU26 NA104 NA100 NA101 NA103 NA102 NA105 NA129 NA130 NA132 NA131 NA21 NA32 NA33 NA37 NA39 NA40 NA42 NA44 NA45 NA46 NA47 NA49 NA50 NA51 NA52 NA53 NA54 NA56 NA57 NA58 NA59 NA60 NA61 NA62 NA63 NA64 NA65 NA66 NA67 NA68 NA69 NA70 NA71 NA72 NA73 NA74 NA75 NA76 NA77 NA78 NA79 NA80 NA81 NA82 NA83 NA84 NA85 NA86 NA87 NA88 NA89 NA90 NA91 NA92 NA93 NA94 NA95 NA96 NA97 NA98 NA99 UM1 UM2 UM3 UM4 UM5

Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.