From dd3d79bc8cfac3bade7815108f02511c88995306 Mon Sep 17 00:00:00 2001 From: Marius Olbertz Date: Sat, 9 Apr 2016 11:58:07 +0200 Subject: [PATCH] Fix for detection of overfloating dropdown menus. Because the selectors were not specific enough, the styles of .opens-right set by the JS in case of an overflowing sub-menu was overwritten by the parent's .open-left styles. Added visual tests to check for this. The tests include two cases: one for a right aligned dropdown using `.top-bar-right` (which was fixed earlier already) and one that is positioned right because of content (where this fix can be tested). Also added anchors to the menu's links to check for correct behavior of the links, e.g. when using keyboard. --- docs/pages/dropdown-menu.md | 83 +++++------ scss/components/_dropdown-menu.scss | 10 +- .../right-aligned-dropdown-menu.html | 135 ++++++++++++++++++ 3 files changed, 175 insertions(+), 53 deletions(-) create mode 100644 test/visual/dropdown-menu/right-aligned-dropdown-menu.html diff --git a/docs/pages/dropdown-menu.md b/docs/pages/dropdown-menu.md index f95c0d108..e9ff92b21 100644 --- a/docs/pages/dropdown-menu.md +++ b/docs/pages/dropdown-menu.md @@ -43,39 +43,39 @@ To create dropdown menus, nest a new ` --- @@ -97,54 +97,41 @@ Add the `.vertical` class to the top-level menu to make it vertical. Sub-menus a --- diff --git a/scss/components/_dropdown-menu.scss b/scss/components/_dropdown-menu.scss index 7ea6c3409..91d73fca3 100644 --- a/scss/components/_dropdown-menu.scss +++ b/scss/components/_dropdown-menu.scss @@ -84,14 +84,14 @@ $dropdownmenu-border-width: nth($dropdownmenu-border, 1); } &.opens-left { - .is-dropdown-submenu { + > .is-dropdown-submenu { left: auto; right: 100%; } } &.opens-right { - .is-dropdown-submenu { + > .is-dropdown-submenu { right: auto; left: 100%; } @@ -164,11 +164,11 @@ $dropdownmenu-border-width: nth($dropdownmenu-border, 1); margin-top: -2px; } - &.opens-inner .is-dropdown-submenu { + &.opens-inner > .is-dropdown-submenu { top: 100%; } - &.opens-left .is-dropdown-submenu { + &.opens-left > .is-dropdown-submenu { left: auto; right: 100%; } @@ -202,7 +202,7 @@ $dropdownmenu-border-width: nth($dropdownmenu-border, 1); // [TODO] Cut back specificity // scss-lint:disable SelectorDepth - &:not(.js-dropdown-nohover) > .is-dropdown-submenu-parent:hover > &, + //&:not(.js-dropdown-nohover) > .is-dropdown-submenu-parent:hover > &, // why is this line needed? Opening is handled by JS and this causes some ugly flickering when the sub is re-positioned automatically... &.js-dropdown-active { display: block; } diff --git a/test/visual/dropdown-menu/right-aligned-dropdown-menu.html b/test/visual/dropdown-menu/right-aligned-dropdown-menu.html new file mode 100644 index 000000000..f00bd6599 --- /dev/null +++ b/test/visual/dropdown-menu/right-aligned-dropdown-menu.html @@ -0,0 +1,135 @@ + + + + + + + + + + + + + +

Dropdown Menu: Right aligned

+

This dropdown menu is aligned right using .top-bar-right class.

+
+ +
Menu
+
+ + + +

This dropdown menu is positioned right just by the content before it.

+
+ +
Menu
+
+ + + + + + + + -- 2.47.3