Skip to content

Commit

Permalink
Fix ctrl-enter on vm start dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Martins committed Sep 27, 2024
1 parent 21d107c commit 3e714d9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions ui/src/views/compute/StartVirtualMachine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
}
}
}
Expand Down

0 comments on commit 3e714d9

Please sign in to comment.