From 5444cdd5da6e08a78c04ff4bdbb4a117f231dd28 Mon Sep 17 00:00:00 2001 From: Stephen James Date: Mon, 9 Nov 2015 15:01:56 -0500 Subject: [PATCH] Allow manual override for auto-flip --- js/dropdown-autoflip.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/js/dropdown-autoflip.js b/js/dropdown-autoflip.js index 82ae2d4ec..a4e326fce 100644 --- a/js/dropdown-autoflip.js +++ b/js/dropdown-autoflip.js @@ -98,21 +98,26 @@ function _getContainer(element) { var containerElement, isWindow; + + // manual override if (element.attr('data-target')) { containerElement = element.attr('data-target'); isWindow = false; } else { + // default to window otherwise containerElement = window; isWindow = true; - } - $.each(element.parents(), function (index, value) { - if ($(value).css('overflow') !== 'visible') { - containerElement = value; - isWindow = false; - return false; - } - }); + // unless there's a parent element with non-visible overflow + $.each(element.parents(), function (index, value) { + if ($(value).css('overflow') !== 'visible') { + containerElement = value; + isWindow = false; + return false; + } + }); + + } return { overflowElement: $(containerElement),