maintain focus on open modals

This commit is contained in:
Andrew Croce 2018-10-18 10:01:07 -04:00
parent 8da22f5941
commit c0719ce85f

View File

@ -1,17 +1,32 @@
import ally from 'ally.js'
export default { export default {
methods: { methods: {
closeModal: function(name) { closeModal: function(name) {
this.activeModal = null this.activeModal = null
this.$emit('modalOpen', false) this.$emit('modalOpen', false)
if (this.allyHandler) this.allyHandler.disengage()
}, },
openModal: function (name) { openModal: function (name) {
this.activeModal = name this.activeModal = name
this.$emit('modalOpen', true) this.$emit('modalOpen', true)
const idSelector = `#${this.modalId}`
this.allyHandler = ally.maintain.disabled({
filter: idSelector
});
} }
}, },
data: function() { data: function() {
return { return {
activeModal: null, activeModal: null,
allyHandler: null
}
},
computed: {
modalId: function () {
return !!this.activeModal ? `modal--${ this.activeModal }` : null
} }
} }
} }