From f1541583abd6a6de945daae3c64a26f6ace5775d Mon Sep 17 00:00:00 2001 From: John Leider Date: Thu, 30 Mar 2017 13:19:59 -0400 Subject: [PATCH] bug fixes for select with data tables --- src/components/menus/Menu.js | 42 +++++++++++++-------- src/components/selects/mixins/generators.js | 9 ++--- src/components/tables/SmallDialog.js | 7 ++-- src/mixins/toggleable.js | 2 +- 4 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/components/menus/Menu.js b/src/components/menus/Menu.js index 4a772293c9f..acd1d69a89c 100755 --- a/src/components/menus/Menu.js +++ b/src/components/menus/Menu.js @@ -76,6 +76,10 @@ export default { type: Boolean, default: true }, + closeOnContentClick: { + type: Boolean, + default: true + }, activator: { default: null }, @@ -185,10 +189,6 @@ export default { activatorXY (val) { this.isActive = true - }, - - value (val) { - this.isActive = val } }, @@ -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) { @@ -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]) @@ -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)]) } } diff --git a/src/components/selects/mixins/generators.js b/src/components/selects/mixins/generators.js index b5ac92f6ed1..23d3e282439 100755 --- a/src/components/selects/mixins/generators.js +++ b/src/components/selects/mixins/generators.js @@ -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, @@ -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) @@ -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 () { diff --git a/src/components/tables/SmallDialog.js b/src/components/tables/SmallDialog.js index 807a6b2c207..e26f1950848 100755 --- a/src/components/tables/SmallDialog.js +++ b/src/components/tables/SmallDialog.js @@ -45,8 +45,8 @@ 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) @@ -54,8 +54,7 @@ export default { }, [ h('a', { domProps: { href: 'javascript:;' }, - slot: 'activator', - ref: 'activator' + slot: 'activator' }, [this.$slots.default]), h('div', { 'class': 'small-dialog__content', diff --git a/src/mixins/toggleable.js b/src/mixins/toggleable.js index 0022908e117..93164026fe7 100755 --- a/src/mixins/toggleable.js +++ b/src/mixins/toggleable.js @@ -11,7 +11,7 @@ export default { watch: { value () { - // this.isActive = this.value + this.isActive = this.value }, isActive () { this.$emit('input', this.isActive)