Skip to content

Commit

Permalink
fix(modal): use listenOnRoot mixin (#593)
Browse files Browse the repository at this point in the history
* [modal] use listenOnRoot mixin
  • Loading branch information
tmorehouse committed Jun 30, 2017
1 parent 0def257 commit 531a6ab
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/components/modal.vue
Expand Up @@ -88,6 +88,7 @@

<script>
import bBtn from './button.vue';
import listenOnRoot from '../mixins/listen-on-root';
const FOCUS_SELECTOR = [
'button:not([disabled])',
Expand Down Expand Up @@ -122,6 +123,7 @@
}
export default {
mixins: [listenOnRoot],
components: {bBtn},
data() {
return {
Expand Down Expand Up @@ -355,21 +357,22 @@
!this.$refs.content.contains(e.target)) {
this.$refs.content.focus();
}
}
},
created() {
this.$root.$on('show::modal', (id, triggerEl) => {
},
showHandler(id, triggerEl) {
if (id === this.id) {
this.return_focus = triggerEl || null;
this.show();
}
});
this.$root.$on('hide::modal', id => {
},
hideHandler(id) {
if (id === this.id) {
this.hide();
}
});
}
},
created() {
this.listenOnRoot('show::modal', this.showHandler);
this.listenOnRoot('hide::modal', this.hideHandler);
},
mounted() {
if (this.visible === true) {
Expand Down

0 comments on commit 531a6ab

Please sign in to comment.