I have a problem with modal windows in the Salesforce One mobile App. My issue is that when the user presses a Submit button, a modal window should pop up and collect more information from the user. The problem is that the modal does not pop up in the viewport and the user has to scroll up and down to find it. With Javascript, I would like to get the relative center of the viewport of the mobile, and position my modal right directly on those X,Y points. I have tried to use the javascript ScrollIntoView(), and scrollTo functions but nothing seems to work in the app. Has anyone ran into this issue before and if so did you find anything that sufficiently corrected it? If need be, I could switch from a Modal popup to a hidden div section.

1 Answer 1


You need to separate your modal from your Lightening Component. Create another Lightening Component with the modal only. So have your first component with the overlayLib call the new modal component. Now it will pop up in the middle of the screen on your mobile. I've spent hours trying to get this work with the embedded modal on the same component, but this is the only way it will work on the salesforce mobile app.

Credit: https://salesforcediaries.com/2018/09/02/modal-popup-in-lightning-experience-using-lightningoverlaylibrary/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.