mirror of
https://github.com/nasa/openmct.git
synced 2025-04-23 10:23:43 +00:00
Multiple modal instances on 'Enter' button #2513
This commit is contained in:
parent
9b7a986475
commit
6b2f2b758d
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="c-overlay">
|
||||
<div class="c-overlay" ref="overlay" tabindex="0">
|
||||
<div class="c-overlay__blocker"
|
||||
@click="destroy">
|
||||
</div>
|
||||
@ -11,6 +11,8 @@
|
||||
<div class="c-overlay__contents" ref="element"></div>
|
||||
<div class="c-overlay__button-bar" v-if="buttons">
|
||||
<button class="c-button"
|
||||
tabindex="0"
|
||||
ref="buttons"
|
||||
v-for="(button, index) in buttons"
|
||||
:key="index"
|
||||
:class="{'c-button--major': button.emphasis}"
|
||||
@ -174,6 +176,9 @@
|
||||
inject: ['dismiss', 'element', 'buttons', 'dismissable'],
|
||||
mounted() {
|
||||
this.$refs.element.appendChild(this.element);
|
||||
setTimeout(() => {
|
||||
this.getFocusElement().focus();
|
||||
}, 0);
|
||||
},
|
||||
methods: {
|
||||
destroy: function () {
|
||||
@ -184,6 +189,17 @@
|
||||
buttonClickHandler: function (method) {
|
||||
method();
|
||||
this.$emit('destroy');
|
||||
},
|
||||
getFocusElement: function () {
|
||||
if (!this.$refs.buttons) {
|
||||
return this.$refs.overlay;
|
||||
}
|
||||
|
||||
const focusButton = this.$refs.buttons.filter((button, index) => {
|
||||
return this.buttons[index].emphasis;
|
||||
});
|
||||
|
||||
return focusButton[0] || this.$refs.buttons[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user