Skip to content

Commit

Permalink
fix bug when $options.modal is not applied when function that resol…
Browse files Browse the repository at this point in the history
…ves to component is passed
  • Loading branch information
andrewvasilchuk committed Nov 10, 2019
1 parent 255d82d commit 604e5a1
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions src/components/VueAccessibleModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
<div class="v-modal__inner">
<div class="v-modal__holder">
<div ref="content" class="v-modal__content">
<component :is="component" v-bind="props" v-on="listeners" @hook:mounted="mountedHook"></component>
<component
:is="component"
ref="component"
v-bind="props"
v-on="listeners"
@hook:mounted="mountedHook"
></component>
</div>
</div>
</div>
Expand All @@ -37,6 +43,8 @@ export default {
component: null,
options: {},
lastFocusedElement: null,
localLabel: '',
localClasses: null,
localAttributes: null,
}
},
Expand All @@ -46,15 +54,15 @@ export default {
return options.transition
},
className() {
const { options, component } = this
const { options, localClasses } = this
const arr = ['v-modal']
if (options && options.classes) {
arr.push(options.classes)
}
if (component && component.modal && component.modal.classes) {
arr.push(component.modal.classes)
if (localClasses) {
arr.push(localClasses)
}
return arr
Expand All @@ -81,15 +89,12 @@ export default {
return {}
},
label() {
const { component, options } = this
return (
options.label || (component && component.modal && component.modal.label)
)
const { options, localLabel } = this
return options.label || localLabel
},
},
created() {
Plugin.event.$on('show', this.show)
Plugin.event.$on('close', this.close)
},
methods: {
Expand All @@ -116,6 +121,9 @@ export default {
}
this.open = false
this.localLabel = ''
this.localClasses = null
this.localAttributes = null
},
getFocusableElements() {
const { modal } = this.$refs
Expand Down Expand Up @@ -168,6 +176,14 @@ export default {
const { modal } = this.$refs.component.$options
if (modal) {
if (modal.label) {
this.localLabel = modal.label
}
if (modal.classes) {
this.localClasses = modal.classes
}
if (modal.attributes) {
this.localAttributes = modal.attributes
}
Expand Down

0 comments on commit 604e5a1

Please sign in to comment.