Skip to content

Disallow enter key to submit form on selecting Autocomplete item (CFM-150) #280

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,16 @@ export default {
}
}
this.listLastPos = itemPosition
},
onEnter(ev) {
if(this.options.type != 'stand-alone'
&& this.person != '') {
// Allow the Enter key to submit the form only if we're in
// stand-alone mode or the field is empty.
ev.preventDefault();
ev.stopPropagation();
return false;
}
}
},
mounted() {
Expand Down Expand Up @@ -310,7 +320,8 @@ export default {
@show="calculateDisabled"
@keyup.arrow-down="onListNavigate"
@keyup.arrow-up="onListNavigate"
@item-select="setPerson">
@item-select="setPerson"
@keydown.enter="onEnter">
<template #option="slotProps">
<div class="cm-ac-item">
<div class="cm-ac-item-primary">
Expand Down