diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-12-07 04:59:29 +0100 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-12-07 15:38:46 +0100 |
commit | 9b1f3b969e8c273d86901432421189295383d81f (patch) | |
tree | fb61cf9990886de5b0ff0235970b8fb56c55798c /apps/comments/js | |
parent | c43f64d56b517e061ceb48e30ebaa48cc7866236 (diff) | |
download | nextcloud-server-9b1f3b969e8c273d86901432421189295383d81f.tar.gz nextcloud-server-9b1f3b969e8c273d86901432421189295383d81f.zip |
Fix Enter sending comment instead of adding autocomplete item to message
When the autocomplete popover is shown the At.js plugin listens on the
message input field for key down events, and when Enter is pressed it
adds the selected item to the message. However, as "_onTypeComment" also
handles key down events for the message input field, when Enter was
pressed the comment was submitted and At.js had no chance to add the
item before that happened. Now when Enter is pressed and the
autocomplete popover is shown the comment is not submitted, and thus
At.js adds the selected item to the message as expected.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/comments/js')
-rw-r--r-- | apps/comments/js/commentstabview.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index 0d752877b04..2ab6349d98a 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -517,8 +517,11 @@ $field.toggleClass('error', limitExceeded); $submitButton.prop('disabled', limitExceeded); - // Submits form with Enter, but Shift+Enter is a new line - if (ev.keyCode === 13 && !ev.shiftKey) { + // Submits form with Enter, but Shift+Enter is a new line. If the + // autocomplete popover is being shown Enter does not submit the + // form either; it will be handled by At.js which will add the + // currently selected item to the message. + if (ev.keyCode === 13 && !ev.shiftKey && !$field.atwho('isSelecting')) { $submitButton.click(); ev.preventDefault(); } |