Skip to content

Commit 6bab2e8

Browse files
authored
fix(dropdown): respect submenu on up/downward height calculation
When the menu contain the child menu, the calculation of menu height is incorrect while evaluating to open upward or downard. It's because the child menu is hidden when the current menu is in the transition of being open and it doesn't occupy any space in the current menu and the height of the current menu is incorrectly calculated without the height of child menu which let the menu opens upward or downward incorrectly. This PR checks if the current menu has the child menu and adds the child menu height to the current menu height to give correct assumption whether the menu fits in the screen upward or downward.
1 parent 8a6f11b commit 6bab2e8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/definitions/modules/dropdown.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,6 +3294,9 @@ $.fn.dropdown = function(parameters) {
32943294
menu: function() {
32953295
return ($menu.length > 0);
32963296
},
3297+
subMenu: function($currentMenu) {
3298+
return ($currentMenu || $menu).find(selector.menu).length > 0;
3299+
},
32973300
message: function() {
32983301
return ($menu.children(selector.message).length !== 0);
32993302
},
@@ -3523,6 +3526,9 @@ $.fn.dropdown = function(parameters) {
35233526
if(module.is.verticallyScrollableContext()) {
35243527
calculations.menu.offset.top += calculations.context.scrollTop;
35253528
}
3529+
if(module.has.subMenu($currentMenu)) {
3530+
calculations.menu.height += $currentMenu.find(selector.menu).first().outerHeight();
3531+
}
35263532
onScreen = {
35273533
above : (calculations.context.scrollTop) <= calculations.menu.offset.top - calculations.context.offset.top - calculations.menu.height,
35283534
below : (calculations.context.scrollTop + calculations.context.height) >= calculations.menu.offset.top - calculations.context.offset.top + calculations.menu.height

0 commit comments

Comments
 (0)