Skip to content
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

Allow to close the actions menu after click #622

Merged
merged 3 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ActionButton/ActionButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This component is made to be used inside of the [Actions](#Actions) component sl
```vue
<Actions>
<ActionButton icon="icon-delete" @click="alert('Delete')">Delete</ActionButton>
<ActionButton icon="icon-delete" @click="alert('Delete')">Delete</ActionButton>
<ActionButton icon="icon-delete" :close-after-click="true" @click="alert('Delete and close menu')">Delete and close</ActionButton>
<ActionButton icon="icon-delete" :disabled="true" @click="alert('Disabled')">Disabled button</ActionButton>
</Actions>
```
Expand Down
15 changes: 15 additions & 0 deletions src/mixins/actionText.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*
*/
import actionGlobal from './actionGlobal'
import GetParent from 'Utils/GetParent'

export default {
mixins: [actionGlobal],
Expand All @@ -39,6 +40,13 @@ export default {
title: {
type: String,
default: ''
},
/**
* Whether we close the Actions menu after the click
*/
closeAfterClick: {
type: Boolean,
default: false
}
},

Expand All @@ -59,6 +67,13 @@ export default {
* @type {Event}
*/
this.$emit('click', event)

if (this.closeAfterClick) {
const parent = GetParent(this, 'Actions')
if (parent && parent.closeMenu) {
parent.closeMenu()
}
}
}
}
}