Skip to content

Commit 305474b

Browse files
author
Bogdan Plieshka
committed
Merge branch 'MAGETWO-35489' into UI
2 parents 66772a0 + 156cb26 commit 305474b

File tree

4 files changed

+92
-48
lines changed

4 files changed

+92
-48
lines changed

app/code/Magento/Backend/Block/Menu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ protected function _renderItemCssClass($menuItem, $level)
191191
$output = ($this->_isItemActive(
192192
$menuItem,
193193
$level
194-
) ? '_active' : '') .
194+
) ? '_current _active' : '') .
195195
' ' .
196196
($menuItem->hasChildren() ? 'parent' : '') .
197197
' ' .

app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/_menu.less

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
@menu__background-color: @color-very-dark-grayish-orange;
1717

18-
@menu-logo__margin-bottom: 2.2rem;
19-
@menu-logo__outer-size: @menu-logo__padding-vertical + @menu-logo-img__height + @menu-logo__margin-bottom;
20-
@menu-logo__padding-vertical: 1.2rem;
18+
@menu-logo__padding-bottom: 2.2rem;
19+
@menu-logo__outer-size: @menu-logo__padding-top + @menu-logo-img__height + @menu-logo__padding-bottom;
20+
@menu-logo__padding-top: 1.2rem;
2121
@menu-logo-img__height: 4.1rem;
2222
@menu-logo-img__width: 3.5rem;
2323

@@ -68,12 +68,27 @@
6868
}
6969
.logo {
7070
display: block;
71-
height: @menu-logo-img__height + @menu-logo__padding-vertical * 2;
72-
margin-bottom: @menu-logo__margin-bottom - @menu-logo__padding-vertical;
73-
padding: @menu-logo__padding-vertical 0;
71+
height: @menu-logo-img__height + @menu-logo__padding-top + @menu-logo__padding-bottom;
72+
padding: @menu-logo__padding-top 0 @menu-logo__padding-bottom;
7473
position: relative;
7574
text-align: center;
7675
z-index: @menu__z-index;
76+
&:focus {
77+
background-color: @menu-item__active__background-color;
78+
box-shadow: none;
79+
+ .admin__menu {
80+
.level-0 {
81+
&:first-child {
82+
> a {
83+
background-color: @menu__background-color;
84+
&:after {
85+
display: none;
86+
}
87+
}
88+
}
89+
}
90+
}
91+
}
7792
&:hover {
7893
.logo-img {
7994
-webkit-filter: brightness(1.1);
@@ -133,7 +148,6 @@
133148
}
134149
// Hover & active state for menu level 0 item
135150
&._active,
136-
&._hover,
137151
&:hover {
138152
> a {
139153
background-color: @menu-item__active__background-color;
@@ -185,19 +199,13 @@
185199
transition: all .5s ease;
186200
visibility: hidden;
187201
z-index: @submenu__z-index;
188-
&._show {
202+
}
203+
&._show {
204+
> .submenu {
189205
left: 100%;
190206
visibility: visible;
191207
}
192208
}
193-
&._recent {
194-
&._hover {
195-
.submenu {
196-
left: 100%;
197-
visibility: visible;
198-
}
199-
}
200-
}
201209
}
202210

203211
.level-1 {

app/design/adminhtml/Magento/backend/web/css/override.less

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3118,13 +3118,22 @@ fieldset[disabled] .admin__control-text + .ui-datepicker-trigger {
31183118
}
31193119
.menu-wrapper .logo {
31203120
display: block;
3121-
height: 6.5rem;
3122-
margin-bottom: 1rem;
3123-
padding: 1.2rem 0;
3121+
height: 7.5rem;
3122+
padding: 1.2rem 0 2.2rem;
31243123
position: relative;
31253124
text-align: center;
31263125
z-index: 700;
31273126
}
3127+
.menu-wrapper .logo:focus {
3128+
background-color: #524d49;
3129+
box-shadow: none;
3130+
}
3131+
.menu-wrapper .logo:focus + .admin__menu .level-0:first-child > a {
3132+
background-color: #373330;
3133+
}
3134+
.menu-wrapper .logo:focus + .admin__menu .level-0:first-child > a:after {
3135+
display: none;
3136+
}
31283137
.menu-wrapper .logo:hover .logo-img {
31293138
-webkit-filter: brightness(1.1);
31303139
filter: brightness(1.1);
@@ -3161,7 +3170,6 @@ fieldset[disabled] .admin__control-text + .ui-datepicker-trigger {
31613170
display: none;
31623171
}
31633172
.admin__menu .level-0._active > a,
3164-
.admin__menu .level-0._hover > a,
31653173
.admin__menu .level-0:hover > a {
31663174
background-color: #524d49;
31673175
color: #f7f3eb;
@@ -3204,11 +3212,7 @@ fieldset[disabled] .admin__control-text + .ui-datepicker-trigger {
32043212
visibility: hidden;
32053213
z-index: 698;
32063214
}
3207-
.admin__menu .level-0 > .submenu._show {
3208-
left: 100%;
3209-
visibility: visible;
3210-
}
3211-
.admin__menu .level-0._recent._hover .submenu {
3215+
.admin__menu .level-0._show > .submenu {
32123216
left: 100%;
32133217
visibility: visible;
32143218
}

app/design/adminhtml/Magento/backend/web/js/theme.js

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ define('globalNavigation', [
1212
$.widget('mage.globalNavigation', {
1313
options: {
1414
selectors: {
15+
menu: '#nav',
16+
currentItem: '._current',
1517
topLevelItem: '.level-0',
1618
topLevelHref: '> a',
1719
subMenu: '> .submenu',
@@ -25,6 +27,7 @@ define('globalNavigation', [
2527

2628
this.menu = this.element;
2729
this.menuLinks = $(selectors.topLevelHref, selectors.topLevelItem);
30+
this.closeActions = $(selectors.closeSubmenuBtn);
2831

2932
this._initOverlay()
3033
._bind();
@@ -37,40 +40,66 @@ define('globalNavigation', [
3740
},
3841

3942
_bind: function () {
40-
var lighten = this._lighten.bind(this),
41-
open = this._open.bind(this),
42-
darken = this._darken.bind(this);
43+
var focus = this._focus.bind(this),
44+
open = this._open.bind(this),
45+
blur = this._blur.bind(this),
46+
keyboard = this._keyboard.bind(this);
4347

4448
this.menuLinks
45-
.on('focus', lighten)
46-
.on('click', open)
47-
.on('blur', darken);
49+
.on('focus', focus)
50+
.on('click', open);
51+
52+
this.menuLinks.last().on('blur', blur);
53+
54+
this.closeActions.on('keydown', keyboard);
55+
},
56+
57+
58+
/**
59+
* Remove active class from current menu item
60+
* Turn back active class to current page menu item
61+
*/
62+
_blur: function(e){
63+
var selectors = this.options.selectors,
64+
menuItem = $(e.target).closest(selectors.topLevelItem),
65+
currentItem = $(selectors.menu).find(selectors.currentItem);
66+
67+
menuItem.removeClass('_active');
68+
currentItem.addClass('_active');
4869
},
4970

50-
_lighten: function (e) {
71+
/**
72+
* Add focus to active menu item
73+
*/
74+
_keyboard: function(e) {
5175
var selectors = this.options.selectors,
5276
menuItem = $(e.target).closest(selectors.topLevelItem);
5377

54-
menuItem
55-
.addClass('_active')
56-
.siblings(selectors.topLevelItem)
57-
.removeClass('_active');
78+
if(e.which === 13) {
79+
this._close(e);
80+
$(selectors.topLevelHref, menuItem).focus();
81+
}
5882
},
5983

60-
_darken: function (e) {
84+
/**
85+
* Toggle active state on focus
86+
*/
87+
_focus: function (e) {
6188
var selectors = this.options.selectors,
6289
menuItem = $(e.target).closest(selectors.topLevelItem);
6390

64-
menuItem.removeClass('_active');
91+
menuItem.addClass('_active')
92+
.siblings(selectors.topLevelItem)
93+
.removeClass('_active');
6594
},
6695

6796
_closeSubmenu: function (e) {
6897
var selectors = this.options.selectors,
69-
menuItem = $(e.target).closest(selectors.topLevelItem);
98+
currentItem = $(selectors.menu).find(selectors.currentItem);
7099

71100
this._close(e);
72101

73-
$(selectors.topLevelHref, menuItem).focus();
102+
currentItem.addClass('_active');
74103
},
75104

76105
_open: function (e) {
@@ -85,33 +114,36 @@ define('globalNavigation', [
85114
e.preventDefault();
86115
}
87116

88-
menuItem
89-
.addClass('_hover _recent')
90-
.siblings(menuItemSelector)
91-
.removeClass('_hover _recent');
117+
menuItem.addClass('_show')
118+
.siblings(menuItemSelector)
119+
.removeClass('_show');
92120

93121
subMenu.attr('aria-expanded', 'true');
94122

95123
closeBtn.on('click', close);
96124

97125
this.overlay.show(0).on('click', close);
126+
this.menuLinks.last().off('blur');
98127
},
99128

100129
_close: function (e) {
101130
var selectors = this.options.selectors,
102-
menuItem = this.menu.find(selectors.topLevelItem + '._hover._recent'),
131+
menuItem = this.menu.find(selectors.topLevelItem + '._show'),
103132
subMenu = $(selectors.subMenu, menuItem),
104-
closeBtn = subMenu.find(selectors.closeSubmenuBtn);
133+
closeBtn = subMenu.find(selectors.closeSubmenuBtn),
134+
blur = this._blur.bind(this);
105135

106136
e.preventDefault();
107137

108138
this.overlay.hide(0).off('click');
109139

140+
this.menuLinks.last().on('blur', blur);
141+
110142
closeBtn.off('click');
111143

112144
subMenu.attr('aria-expanded', 'false');
113145

114-
menuItem.removeClass('_hover _recent');
146+
menuItem.removeClass('_show _active');
115147
}
116148
});
117149

0 commit comments

Comments
 (0)