Fix: Prevent enter in modal from submitting form

This commit is contained in:
Nelson Chan 2021-09-14 12:25:31 +08:00
parent 7c4b5f189b
commit 74da02da2c

View File

@ -53,7 +53,11 @@
</vue-multiselect> </vue-multiselect>
<div v-if="newDraftTag.select?.name == null" class="d-flex mb-2"> <div v-if="newDraftTag.select?.name == null" class="d-flex mb-2">
<div class="w-50 pe-2"> <div class="w-50 pe-2">
<input v-model="newDraftTag.name" class="form-control" :class="{'is-invalid': validateDraftTag.nameInvalid}" :placeholder="$t('name')" /> <input v-model="newDraftTag.name" class="form-control"
:class="{'is-invalid': validateDraftTag.nameInvalid}"
:placeholder="$t('name')"
@keydown.enter.prevent="onEnter"
/>
<div class="invalid-feedback"> <div class="invalid-feedback">
{{ $t("Tag with this name already exist.") }} {{ $t("Tag with this name already exist.") }}
</div> </div>
@ -90,7 +94,11 @@
</div> </div>
</div> </div>
<div class="mb-2"> <div class="mb-2">
<input v-model="newDraftTag.value" class="form-control" :class="{'is-invalid': validateDraftTag.valueInvalid}" :placeholder="$t('value (optional)')" /> <input v-model="newDraftTag.value" class="form-control"
:class="{'is-invalid': validateDraftTag.valueInvalid}"
:placeholder="$t('value (optional)')"
@keydown.enter.prevent="onEnter"
/>
<div class="invalid-feedback"> <div class="invalid-feedback">
{{ $t("Tag with this value already exist.") }} {{ $t("Tag with this value already exist.") }}
</div> </div>
@ -308,6 +316,11 @@ export default {
this.$root.getSocket().emit("deleteMonitorTag", tagId, monitorId, value, resolve); this.$root.getSocket().emit("deleteMonitorTag", tagId, monitorId, value, resolve);
}); });
}, },
onEnter() {
if (!this.validateDraftTag.invalid) {
this.addDraftTag();
}
},
async submit(monitorId) { async submit(monitorId) {
console.log(`Submitting tag changes for monitor ${monitorId}...`); console.log(`Submitting tag changes for monitor ${monitorId}...`);
this.processing = true; this.processing = true;