I need to optimize a component for Salesforce One mobile experience.
Imagine a search form that contains several input fields and a button at the end. The form occupies entire screen.
When the search results are retrieved (on button press), they appear below the form and the user have to scroll down himself to see the results.
Question:
Upon results retrieval how to set the focus on the first result component so that the user wouldn't have to scroll down to see the results? Given that .getElementById('').focus() is not working due to Locker Service limitation.If it's not possible technically, what can be an alternative solution?
tried and failed so far:
- document.getElementById().focus(); //LockerService
- component.find().getElement().focus(); //LockerService
- window.location.hash = id; //doesn't work in salesforce one mobile app
- scrollTo aura event //is not supported in lightning
- window.scrollTo(0, 500); // no effect in S1
Possible way to solution:
- hack salesforce one scroller somehow (something similar to https://salesforce.stackexchange.com/a/83070/27814)
Example code:
<!--FORM occupying mobile screen-->
<div aura:id="formDiv">
<c:Form />
</div>
<!--RESULT LIST appears below the form but the user's screen is still on the form -->
<div aura:id="resultDiv">
<aura:iteration items="{!v.results}" var="result">
<c:ResultListItem result="{!result}"/>
</aura:iteration>
</div>