Skip to content

Commit

Permalink
bug fixes for select with data tables
Browse files Browse the repository at this point in the history
  • Loading branch information
John Leider committed Mar 30, 2017
1 parent 6fff4df commit f154158
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 26 deletions.
42 changes: 26 additions & 16 deletions src/components/menus/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ export default {
type: Boolean,
default: true
},
closeOnContentClick: {
type: Boolean,
default: true
},
activator: {
default: null
},
Expand Down Expand Up @@ -185,10 +189,6 @@ export default {

activatorXY (val) {
this.isActive = true
},

value (val) {
this.isActive = val
}
},

Expand Down Expand Up @@ -227,7 +227,7 @@ export default {
},

activatorClickHandler () {
if (this.openOnClick && !this.isActive) this.isActive = !this.isActive && !this.disabled
if (this.openOnClick) this.isActive = !this.isActive && !this.disabled
},

addActivatorEvents (activator = null) {
Expand Down Expand Up @@ -390,7 +390,15 @@ export default {
name: 'show',
value: this.isContentActive
}],
'class': { 'menu__content': true }
'class': { 'menu__content': true },
on: {
click: e => {
if (this.closeOnContentClick) {
e.stopPropagation()
this.isActive = false
}
}
}
}

return h('div', data, [this.isBooted ? this.$slots.default : null])
Expand Down Expand Up @@ -432,21 +440,23 @@ export default {
'class': {
'menu': true
},
directives: [
{
name: 'click-outside',
value: e => {
const a = this.activator
if (!this.closeOnClick || a && (a === e.target || a.contains(e.target))) return false
return true
}
}
],
directives: [],
on: {
'keyup': e => { if (e.keyCode === 27) this.isActive = false }
}
}

if (this.closeOnClick) {
data.directives.push({
name: 'click-outside',
value: e => {
const a = this.activator
if (a && (a === e.target || a.contains(e.target))) return false
return true
}
})
}

return h('div', data, [this.genActivator(h), this.genTransition(h)])
}
}
9 changes: 4 additions & 5 deletions src/components/selects/mixins/generators.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
ref: 'menu',
props: {
auto: this.auto,
closeOnClick: !this.multiple,
closeOnContentClick: !this.multiple,
disabled: this.disabled,
offsetY: this.autocomplete || this.offset,
value: this.menuActive,
Expand All @@ -15,9 +15,7 @@ export default {
nudgeXAuto: this.multiple ? -40 : -16,
nudgeWidth: 25,
maxHeight: this.maxHeight,
activator: this.$refs.activator,
top: this.top || !this.bottom,
bottom: this.bottom
activator: this.$refs.activator
},
on: {
input: val => (this.menuActive = val)
Expand Down Expand Up @@ -55,7 +53,8 @@ export default {

return this.$createElement('div', {
'class': 'input-group__selections',
style: { 'overflow': 'hidden' }
style: { 'overflow': 'hidden' },
ref: 'activator'
}, [group, input])
},
genSelections () {
Expand Down
7 changes: 3 additions & 4 deletions src/components/tables/SmallDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,16 @@ export default {
transition: this.transition,
origin: 'top right',
right: true,
activator: this.$refs.activator,
value: this.isActive
value: this.isActive,
closeOnContentClick: false
},
on: {
input: val => (this.isActive = val)
}
}, [
h('a', {
domProps: { href: 'javascript:;' },
slot: 'activator',
ref: 'activator'
slot: 'activator'
}, [this.$slots.default]),
h('div', {
'class': 'small-dialog__content',
Expand Down
2 changes: 1 addition & 1 deletion src/mixins/toggleable.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {

watch: {
value () {
// this.isActive = this.value
this.isActive = this.value
},
isActive () {
this.$emit('input', this.isActive)
Expand Down

0 comments on commit f154158

Please sign in to comment.