diff --git a/js/src/dropdown.js b/js/src/dropdown.js index ce25e96711..33171cf20b 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -64,8 +64,13 @@ const Dropdown = (($) => { VISIBLE_ITEMS : '.dropdown-menu .dropdown-item:not(.disabled)' } + const AttachmentMap = { + TOP : 'top', + BOTTOM : 'bottom' + } + const Default = { - placement : 'bottom', + placement : AttachmentMap.BOTTOM, offset : 0 } @@ -141,8 +146,10 @@ const Dropdown = (($) => { return false } + // Handle dropup + const dropdownPlacement = $(this).parent().hasClass('dropup') ? AttachmentMap.TOP : context._config.placement this._popper = new Popper(this, context._menu, { - placement : context._config.placement, + placement : dropdownPlacement, modifiers : { offset : { offset : context._config.offset diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index f47a97e30c..c0cafefe51 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -456,7 +456,7 @@ $(function () { assert.expect(1) var done = assert.async() - var containerHTML = '
' + 'Hover me' + '
' @@ -482,7 +482,12 @@ $(function () { }) .on('shown.bs.tooltip', function () { var $tooltip = $($(this).data('bs.tooltip').tip) - assert.ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) >= Math.round($(this).offset().top)) + if (/iPhone|iPad|iPod/.test(navigator.userAgent)) { + assert.ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) <= Math.round($(this).offset().top)) + } + else { + assert.ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) >= Math.round($(this).offset().top)) + } done() }) .bootstrapTooltip('show') diff --git a/js/tests/visual/dropdown.html b/js/tests/visual/dropdown.html index d96b367e99..45c5d51722 100644 --- a/js/tests/visual/dropdown.html +++ b/js/tests/visual/dropdown.html @@ -58,6 +58,19 @@