Skip to content

Commit

Permalink
Disallow enter key to submit form on selecting Autocomplete item (CFM…
Browse files Browse the repository at this point in the history
…-150) (#280)

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

* Disallow enter key for all but stand-alone people pickers on select (CFM-150)

* Allow enter key when people-picker field is empty (CFM-150)
  • Loading branch information
arlen authored Feb 4, 2025
1 parent e6a5002 commit 7c9591d
Showing 1 changed file with 12 additions and 1 deletion.
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

0 comments on commit 7c9591d

Please sign in to comment.