Fixed bug in desktop navigation causing dropdown menu to get stuck until moused over again.

This commit is contained in:
alexthomson1
2020-01-11 23:16:24 -07:00
parent 8fd7e1cd00
commit 8bd27b8313
2 changed files with 26 additions and 17 deletions

View File

@@ -35,14 +35,16 @@
line-height: 1.71; line-height: 1.71;
color: $gray-50; color: $gray-50;
cursor: pointer; cursor: pointer;
background-color: $purple-200;
&:focus { &:focus {
outline: none; outline: none;
background-color: inherit; background-color: inherit;
} }
&:active, &:hover, &.active { &:active, &:hover, &.active {
background-color: rgba(#d5c8ff, 0.32); background-color: #6133B4;
color: $purple-200; color: $purple-200;
} }
@@ -50,7 +52,7 @@
cursor: default; cursor: default;
&:active, &:hover, &.active { &:active, &:hover, &.active {
background-color: inherit; background-color: $purple-200;
color: inherit; color: inherit;
} }
} }

View File

@@ -58,8 +58,7 @@
<li <li
class="topbar-item droppable" class="topbar-item droppable"
:class="{ :class="{
'active': $route.path.startsWith('/inventory'), 'active': $route.path.startsWith('/inventory')}"
'down': $route.path.startsWith('/inventory') && isDesktop()}"
> >
<div <div
class="chevron rotate" class="chevron rotate"
@@ -102,8 +101,7 @@
<li <li
class="topbar-item droppable" class="topbar-item droppable"
:class="{ :class="{
'active': $route.path.startsWith('/shop'), 'active': $route.path.startsWith('/shop')}"
'down': $route.path.startsWith('/shop') && isDesktop()}"
> >
<div <div
class="chevron rotate" class="chevron rotate"
@@ -169,8 +167,7 @@
<li <li
class="topbar-item droppable" class="topbar-item droppable"
:class="{ :class="{
'active': $route.path.startsWith('/groups'), 'active': $route.path.startsWith('/groups')}"
'down': $route.path.startsWith('/groups') && isDesktop()}"
> >
<div <div
class="chevron rotate" class="chevron rotate"
@@ -212,8 +209,7 @@
<li <li
class="topbar-item droppable" class="topbar-item droppable"
:class="{ :class="{
'active': $route.path.startsWith('/group-plans'), 'active': $route.path.startsWith('/group-plans')}"
'down': $route.path.startsWith('/group-plans') && isDesktop()}"
> >
<div <div
v-if="groupPlans.length > 0" v-if="groupPlans.length > 0"
@@ -246,8 +242,7 @@
<li <li
class="topbar-item droppable" class="topbar-item droppable"
:class="{ :class="{
'active': $route.path.startsWith('/challenges'), 'active': $route.path.startsWith('/challenges')}"
'down': $route.path.startsWith('/challenges') && isDesktop()}"
> >
<div <div
class="chevron rotate" class="chevron rotate"
@@ -283,8 +278,7 @@
<li <li
class="topbar-item droppable" class="topbar-item droppable"
:class="{ :class="{
'active': $route.path.startsWith('/help'), 'active': $route.path.startsWith('/help')}"
'down': $route.path.startsWith('/help') && isDesktop()}"
> >
<div <div
class="chevron rotate" class="chevron rotate"
@@ -809,7 +803,11 @@ export default {
}, },
dropdownDesktop (hover) { dropdownDesktop (hover) {
if (this.isDesktop() && hover.target.classList.contains('droppable')) { if (this.isDesktop() && hover.target.classList.contains('droppable')) {
this.dropdown(hover.target); if (hover.type === 'mouseenter') {
this.openDropdown(hover.target);
} else {
this.closeDropdown(hover.target);
}
} }
}, },
dropdownMobile (click) { dropdownMobile (click) {
@@ -827,6 +825,15 @@ export default {
element.classList.toggle('down'); element.classList.toggle('down');
element.lastChild.style.maxHeight = element.classList.contains('down') ? `${element.lastChild.scrollHeight}px` : 0; element.lastChild.style.maxHeight = element.classList.contains('down') ? `${element.lastChild.scrollHeight}px` : 0;
}, },
closeDropdown (element) {
element.classList.remove('down');
element.lastChild.style.maxHeight = 0;
},
openDropdown (element) {
element.classList.add('down');
element.lastChild.style.maxHeight = `${element.lastChild.scrollHeight}px`;
},
closeMenu () { closeMenu () {
if (this.isMobile()) { if (this.isMobile()) {
this.menuIsOpen = false; this.menuIsOpen = false;