bootstrap: Dynamically loaded Bootstrap Modal does not scroll on iOS 9

Using Bootstrap 3, when I load content into a modal on the show event, scrolling on iOS 9 devices does not work. It works correctly on every other device that I’ve tried, including iOS 8. I think the DOM doesn’t update the <div>'s scroll height, so it doesn’t think the modal should be scrollable. The handleUpdate function doesn’t fix the issue, either.

I’ve created a minimal example on Codepen at http://codepen.io/jkrehm/full/LpRzJV/ (code available here).

The most relevant code is this:

// Show loader & then get content when modal is shown
$modal.on('show.bs.modal', function(e) {
    $(this).find('.modal-body')
        .html('loading...')
        .load('https://baconipsum.com/api/?type=meat-and-filler&paras=10', function() {
            // Use Bootstrap's built-in function to fix scrolling (to no avail)
            $modal.modal('handleUpdate');
        });
});

If I change the code so the content is loaded before the modal is shown, things work fine, but there’s no loading indicator for the user (just a pause of indeterminate length after they click the button and before the modal appears).

What can we do to convince iOS 9 to recalculate the .modal-body’s scroll height? I’ve tried a number of things, and the only “work around” that works reliably is to hide .modal-body and show it again.

I’ve also created a StackOverflow question in case someone else runs into the issue and figures out a fix.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 17 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Seems to be a bug in -webkit-overflow-scrolling. Setting .modal { -webkit-overflow-scrolling: auto; } causes the bug to stop reproducing.

Adding this inside the modal div fixed it for me style=“overflow-y: auto;”