Skip to content

Commit 8608f28

Browse files
lucas-a-martinsLucas Martins
and
Lucas Martins
authored
Fix ctrl-enter on vm start dialog (#9743)
Co-authored-by: Lucas Martins <lucas.martins@scclouds.com.br>
1 parent f7b7339 commit 8608f28

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

ui/src/views/compute/StartVirtualMachine.vue

+14-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// under the License.
1717

1818
<template>
19-
<div class="form-layout" v-ctrl-enter="handleSubmit">
19+
<div class="form-layout">
2020
<a-spin :spinning="loading">
2121
<a-alert type="warning">
2222
<template #message>{{ $t('message.action.start.instance') }}</template>
@@ -93,7 +93,7 @@
9393
<template #label>
9494
<tooltip-label :title="$t('label.considerlasthost')" :tooltip="apiParams.considerlasthost.description"/>
9595
</template>
96-
<a-switch v-model:checked="form.considerlasthost" />
96+
<a-switch v-model:checked="form.considerlasthost" v-focus="true"/>
9797
</a-form-item>
9898
</div>
9999

@@ -151,6 +151,12 @@ export default {
151151
this.fetchHosts()
152152
}
153153
},
154+
mounted () {
155+
document.addEventListener('keydown', this.handleKeyPress)
156+
},
157+
beforeUnmount () {
158+
document.removeEventListener('keydown', this.handleKeyPress)
159+
},
154160
methods: {
155161
initForm () {
156162
this.formRef = ref()
@@ -264,6 +270,12 @@ export default {
264270
},
265271
closeAction () {
266272
this.$emit('close-action')
273+
},
274+
handleKeyPress (event) {
275+
event.preventDefault()
276+
if ((event.code === 'Enter' || event.code === 'NumpadEnter') && event.ctrlKey === true) {
277+
this.handleSubmit(event)
278+
}
267279
}
268280
}
269281
}

0 commit comments

Comments
 (0)