Skip to content
Snippets Groups Projects
Commit 3a2588f8 authored by Aymeric Chaumont's avatar Aymeric Chaumont
Browse files

allowed to send comment after having pressed the enter key

parent 4bf6e99c
No related branches found
No related tags found
1 merge request!56Front adjustments
......@@ -138,7 +138,11 @@ export default function Messages({ place, infos, lastMessage, admin }) {
let new_message = JSON.parse(lastMessage.data);
if (new_message.type == "news" && infos) {
setMessages((old_messages) => [new_message.comment, ...old_messages]);
} else if (!infos && new_message.type == "comment" && new_message.comment.username != user) {
} else if (
!infos &&
new_message.type == "comment" &&
new_message.comment.username != user.name
) {
setMessages((old_messages) => [...old_messages, new_message.comment]);
}
}
......@@ -208,6 +212,12 @@ export default function Messages({ place, infos, lastMessage, admin }) {
value={newComment}
onChange={(ev) => updateValue(ev.target.value)}
placeholder="Ajouter un commentaire"
onKeyDown={(ev) => {
if (ev.key === "Enter" && ev.shiftKey == false) {
ev.preventDefault();
Submit(ev);
}
}}
/>
<button className="comment-input-button" onClick={Submit}>
<BiSend />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment