Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix modal backdrop overlaying the modal's scrollbar #14927

Merged
merged 1 commit into from Nov 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions js/modal.js
Expand Up @@ -60,6 +60,7 @@

this.setScrollbar()
this.escape()
if (this.options.backdrop) this.resize()

this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))

Expand All @@ -74,6 +75,8 @@
.show()
.scrollTop(0)

if (that.options.backdrop) that.setBackdropHeight()

if (transition) {
that.$element[0].offsetWidth // force reflow
}
Expand Down Expand Up @@ -108,6 +111,7 @@
this.isShown = false

this.escape()
if (this.options.backdrop) this.resize()

$(document).off('focusin.bs.modal')

Expand Down Expand Up @@ -143,6 +147,14 @@
}
}

Modal.prototype.resize = function () {
if (this.isShown) {
$(window).on('resize.bs.modal', $.proxy(this.setBackdropHeight, this))
} else {
$(window).off('resize.bs.modal')
}
}

Modal.prototype.hideModal = function () {
var that = this
this.$element.hide()
Expand Down Expand Up @@ -204,6 +216,12 @@
}
}

Modal.prototype.setBackdropHeight = function () {
this.$backdrop
.css('height', 0)
.css('height', this.$element[0].scrollHeight)
}

Modal.prototype.checkScrollbar = function () {
this.scrollbarWidth = this.measureScrollbar()
}
Expand Down
3 changes: 1 addition & 2 deletions less/modals.less
Expand Up @@ -62,10 +62,9 @@

// Modal background
.modal-backdrop {
position: fixed;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was bottom: 0 removed? It results in the modal's backdrop having height 0 and thus not being displayed for me.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue here +1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #15314 / #15345.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Removing bottom: 0; causes the calculated height of .modal-backdrop to be 0.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 this is now broken

background-color: @modal-backdrop-bg;
// Fade for backdrop
Expand Down