Skip to content

Commit

Permalink
Merge branch 'v4-dev' into v4-dev-mc-text-monospace-important
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Jan 24, 2019
2 parents e80296f + 3723613 commit 4c5d96c
Show file tree
Hide file tree
Showing 23 changed files with 1,226 additions and 762 deletions.
12 changes: 11 additions & 1 deletion .stylelintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"extends": [
"stylelint-config-twbs-bootstrap/scss"
]
],
"rules": {
"property-blacklist": [
"border-radius",
"border-top-left-radius",
"border-top-right-radius",
"border-bottom-right-radius",
"border-bottom-left-radius",
"transition"
]
}
}
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.5.2)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
colorator (1.1.0)
concurrent-ruby (1.1.4)
Expand Down Expand Up @@ -47,9 +47,9 @@ GEM
ruby_dep (~> 1.2)
mercenary (0.3.6)
mini_portile2 (2.4.0)
nokogiri (1.10.0)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
nokogiri (1.10.0-x64-mingw32)
nokogiri (1.10.1-x64-mingw32)
mini_portile2 (~> 2.4.0)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
Expand Down
9 changes: 8 additions & 1 deletion js/src/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const Event = {
}

const ClassName = {
SCROLLABLE : 'modal-dialog-scrollable',
SCROLLBAR_MEASURER : 'modal-scrollbar-measure',
BACKDROP : 'modal-backdrop',
OPEN : 'modal-open',
Expand All @@ -60,6 +61,7 @@ const ClassName = {

const Selector = {
DIALOG : '.modal-dialog',
MODAL_BODY : '.modal-body',
DATA_TOGGLE : '[data-toggle="modal"]',
DATA_DISMISS : '[data-dismiss="modal"]',
FIXED_CONTENT : '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
Expand Down Expand Up @@ -244,7 +246,12 @@ class Modal {
this._element.style.display = 'block'
this._element.removeAttribute('aria-hidden')
this._element.setAttribute('aria-modal', true)
this._element.scrollTop = 0

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

if (transition) {
Util.reflow(this._element)
Expand Down
3 changes: 2 additions & 1 deletion js/tests/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env node */
/* eslint no-process-env: 0 */

const path = require('path')
const ip = require('ip')
const {
browsers,
Expand Down Expand Up @@ -114,7 +115,7 @@ if (bundle) {
conf.customLaunchers = customLaunchers
conf.detectBrowsers = detectBrowsers
conf.coverageIstanbulReporter = {
dir: '../coverage/',
dir: path.resolve(__dirname, '../coverage/'),
reports: ['lcov', 'text-summary'],
thresholds: {
emitWarning: false,
Expand Down
27 changes: 27 additions & 0 deletions js/tests/unit/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,4 +790,31 @@ $(function () {
})
.bootstrapModal('show')
})

QUnit.test('should scroll to top of the modal body if the modal has .modal-dialog-scrollable class', function (assert) {
assert.expect(2)
var done = assert.async()

var $modal = $([
'<div id="modal-test">',
' <div class="modal-dialog modal-dialog-scrollable">',
' <div class="modal-content">',
' <div class="modal-body" style="height: 100px; overflow-y: auto;">',
' <div style="height: 200px" />',
' </div>',
' </div>',
' </div>',
'</div>'
].join('')).appendTo('#qunit-fixture')

var $modalBody = $('.modal-body')
$modalBody.scrollTop(100)
assert.strictEqual($modalBody.scrollTop(), 100)

$modal.on('shown.bs.modal', function () {
assert.strictEqual($modalBody.scrollTop(), 0, 'modal body scrollTop should be 0 when opened')
done()
})
.bootstrapModal('show')
})
})
Loading

0 comments on commit 4c5d96c

Please sign in to comment.