From c0719ce85f93c4a7721cee509f9e2d53531f38ea Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Thu, 18 Oct 2018 10:01:07 -0400 Subject: [PATCH] maintain focus on open modals --- js/mixins/modal.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/js/mixins/modal.js b/js/mixins/modal.js index df168c59..b1d7a376 100644 --- a/js/mixins/modal.js +++ b/js/mixins/modal.js @@ -1,17 +1,32 @@ +import ally from 'ally.js' + export default { methods: { closeModal: function(name) { this.activeModal = null this.$emit('modalOpen', false) + if (this.allyHandler) this.allyHandler.disengage() }, + openModal: function (name) { this.activeModal = name this.$emit('modalOpen', true) + const idSelector = `#${this.modalId}` + + this.allyHandler = ally.maintain.disabled({ + filter: idSelector + }); } }, data: function() { return { activeModal: null, + allyHandler: null + } + }, + computed: { + modalId: function () { + return !!this.activeModal ? `modal--${ this.activeModal }` : null } } }