2
0
mirror of https://github.com/tenrok/vue-context.git synced 2026-06-25 04:00:33 +03:00

Close on click (#9)

This commit is contained in:
Randall Wilk
2018-09-12 12:41:31 -05:00
committed by GitHub
parent 179adf2d6e
commit 0e23700464
7 changed files with 186 additions and 156 deletions
+5
View File
@@ -1,5 +1,10 @@
# Changelog # Changelog
# 3.2.0 (Sep 12, 2018)
### Added
- Prop to tell context menu not to close automatically on click ([issue #8](https://github.com/rawilk/vue-context/issues/8))
## 3.1.1 (June 23, 2018) ## 3.1.1 (June 23, 2018)
### Updated ### Updated
+1
View File
@@ -148,6 +148,7 @@ new Vue({
| Property | Type | Default | Description | Property | Type | Default | Description
| -------- | ---- | ------- | ----------- | -------- | ---- | ------- | -----------
| `closeOnClick` | Boolean | `true` | If set to false, context menu will not automatically close when clicked on.
| `closeOnScroll` | Boolean | `true` | If set to true, context menu will automatically close on window scroll. | `closeOnScroll` | Boolean | `true` | If set to true, context menu will automatically close on window scroll.
## Credits ## Credits
+1 -1
View File
File diff suppressed because one or more lines are too long
+25 -1
View File
@@ -4,7 +4,7 @@
:style="style" :style="style"
tabindex="-1" tabindex="-1"
@blur="close" @blur="close"
@click="close" @click="onClick"
@contextmenu.capture.prevent @contextmenu.capture.prevent
> >
<slot :data="data"></slot> <slot :data="data"></slot>
@@ -14,6 +14,21 @@
<script> <script>
export default { export default {
props: { props: {
/**
* Close the menu on click.
*
* @type {boolean}
*/
closeOnClick: {
type: Boolean,
default: true
},
/**
* Close the menu automatically on window scroll.
*
* @type {boolean}
*/
closeOnScroll: { closeOnScroll: {
type: Boolean, type: Boolean,
default: true default: true
@@ -72,6 +87,15 @@
this.show = false; this.show = false;
}, },
/**
* Close the menu if `closeOnClick` is set to true.
*/
onClick () {
if (this.closeOnClick) {
this.close();
}
},
/** /**
* Open the context menu. * Open the context menu.
* *
+1 -1
View File
@@ -10,7 +10,7 @@
Right click on me Right click on me
</p> </p>
<vue-context ref="menu" :close-on-scroll="close"> <vue-context ref="menu" :close-on-scroll="close" :close-on-click="false">
<ul slot-scope="child"> <ul slot-scope="child">
<li @click="onClick(child.data)">Option 1 {{ child.data && child.data.foo }}</li> <li @click="onClick(child.data)">Option 1 {{ child.data && child.data.foo }}</li>
<li>Option 2</li> <li>Option 2</li>
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long