New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix($theme-default): navbar dropdown issue (fix #2349) #2339
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,13 @@ | |
<div | ||
class="dropdown-wrapper" | ||
:class="{ open }" | ||
@focusout="close(true)" | ||
> | ||
<button | ||
class="dropdown-title" | ||
type="button" | ||
:aria-label="dropdownAriaLabel" | ||
@click="setOpen(!open)" | ||
@click="toggle" | ||
> | ||
<span class="title">{{ item.text }}</span> | ||
<span | ||
|
@@ -44,7 +45,7 @@ | |
@focusout=" | ||
isLastItemOfArray(childSubItem, subItem.items) && | ||
isLastItemOfArray(subItem, item.items) && | ||
setOpen(false) | ||
close() | ||
" | ||
/> | ||
</li> | ||
|
@@ -53,7 +54,7 @@ | |
<NavLink | ||
v-else | ||
:item="subItem" | ||
@focusout="isLastItemOfArray(subItem, item.items) && setOpen(false)" | ||
@focusout="isLastItemOfArray(subItem, item.items) && close()" | ||
/> | ||
</li> | ||
</ul> | ||
|
@@ -75,13 +76,18 @@ export default { | |
}, | ||
|
||
props: { | ||
inSidebar: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'll only display in sidebar if the device is mobile, so it seems that you only need one of them ( |
||
type: Boolean, | ||
default: false | ||
}, | ||
item: { | ||
required: true | ||
} | ||
}, | ||
|
||
data () { | ||
return { | ||
isMobile: false, | ||
open: false | ||
} | ||
}, | ||
|
@@ -98,9 +104,19 @@ export default { | |
} | ||
}, | ||
|
||
mounted () { | ||
this.isMobile = 'ontouchstart' in document.documentElement | ||
}, | ||
|
||
methods: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The methods isn't intuitive. The close won't really close, and what |
||
setOpen (value) { | ||
this.open = value | ||
toggle (event) { | ||
const isButton = event.detail === 0 | ||
|
||
if (this.inSidebar || this.isMobile || isButton) this.open = !this.open | ||
}, | ||
|
||
close (judge) { | ||
if (!judge || (judge && this.isMobile)) this.open = false | ||
}, | ||
|
||
isLastItemOfArray (item, array) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<template> | ||
<aside class="sidebar"> | ||
<NavLinks /> | ||
<NavLinks :in-sidebar="true" /> | ||
|
||
<slot name="top" /> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
close
method will only really close when the arg is false or the device is mobile, and it will never happen here.