Fix ctrl-enter on vm start dialog (#9743)

Co-authored-by: Lucas Martins <lucas.martins@scclouds.com.br>
This commit is contained in:
Lucas Martins 2024-11-13 10:16:49 -03:00 committed by GitHub
parent f7b7339bcf
commit 8608f28842
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,7 +16,7 @@
// under the License.
<template>
<div class="form-layout" v-ctrl-enter="handleSubmit">
<div class="form-layout">
<a-spin :spinning="loading">
<a-alert type="warning">
<template #message>{{ $t('message.action.start.instance') }}</template>
@ -93,7 +93,7 @@
<template #label>
<tooltip-label :title="$t('label.considerlasthost')" :tooltip="apiParams.considerlasthost.description"/>
</template>
<a-switch v-model:checked="form.considerlasthost" />
<a-switch v-model:checked="form.considerlasthost" v-focus="true"/>
</a-form-item>
</div>
@ -151,6 +151,12 @@ export default {
this.fetchHosts()
}
},
mounted () {
document.addEventListener('keydown', this.handleKeyPress)
},
beforeUnmount () {
document.removeEventListener('keydown', this.handleKeyPress)
},
methods: {
initForm () {
this.formRef = ref()
@ -264,6 +270,12 @@ export default {
},
closeAction () {
this.$emit('close-action')
},
handleKeyPress (event) {
event.preventDefault()
if ((event.code === 'Enter' || event.code === 'NumpadEnter') && event.ctrlKey === true) {
this.handleSubmit(event)
}
}
}
}