Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Issues
  • #28906
Closed
Open
Issue created Jun 15, 2019 by Administrator@rootContributor

4.3: modal-dialog-scrollable prevents modal from displaying when modal-body is missing

Created by: ZenRun

In bootstrap 4.3 modal-dialog-scrollable was introduced. When used, bootstrap.js always tries to set scrollTop = 0 on the .modal-body

if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE)) { this._dialog.querySelector(Selector$5.MODAL_BODY).scrollTop = 0; }

If the modal-body class is missing (say when dynamic content was loaded into the modal-content and the backend threw an error message, not wrapped in a modal-body), the browser will not display the modal at all and instead throw the error

Cannot set property 'scrollTop' of null`

chrome 74

null is not an object (evaluating 'this._dialog.querySelector(de).scrollTop=0')

safari Version 12.1.1

See this pen for an example https://codepen.io/Bugreviews/pen/MMKzZv click the button and watch the developer console

A simply solution is to check if the modal body is available with the following code.

if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE)) { if(this._dialog.querySelector(Selector$5.MODAL_BODY)) { this._dialog.querySelector(Selector$5.MODAL_BODY).scrollTop = 0; } }

Assignee
Assign to
Time tracking