fix: note creator fixes

This commit is contained in:
Alejandro Gomez 2023-01-16 11:35:57 +01:00
parent 7a6d5f53be
commit 6ce852e888
No known key found for this signature in database
GPG Key ID: 4DF39E566658C817

View File

@ -27,10 +27,10 @@ export function NoteCreator(props) {
console.debug("Sending note: ", ev); console.debug("Sending note: ", ev);
publisher.broadcast(ev); publisher.broadcast(ev);
setNote(""); setNote("");
setActive(false);
if (typeof onSend === "function") { if (typeof onSend === "function") {
onSend(); onSend();
} }
setActive(false);
} }
async function attachFile() { async function attachFile() {
@ -58,20 +58,22 @@ export function NoteCreator(props) {
} }
} }
function onSubmit(ev) {
ev.stopPropagation();
sendNote()
}
if (!show) return false; if (!show) return false;
return ( return (
<> <>
<div <div className={`flex note-creator ${replyTo ? 'note-reply' : ''}`}>
key={replyTo ? `note-reply-${replyTo.Id}` : `note-creator`}
className={`flex note-creator ${replyTo ? 'note-reply' : ''}`}
>
<div className="flex f-col mr10 f-grow"> <div className="flex f-col mr10 f-grow">
<Textarea <Textarea
autoFocus={autoFocus} autoFocus={autoFocus}
className={`textarea ${active ? "textarea--focused" : ""}`} className={`textarea ${active ? "textarea--focused" : ""}`}
users={users} users={users}
onChange={onChange} onChange={onChange}
onBlur={() => setActive(false)} value={note}
onFocus={() => setActive(true)} onFocus={() => setActive(true)}
/> />
{active && note && ( {active && note && (
@ -80,7 +82,9 @@ export function NoteCreator(props) {
{error.length > 0 ? <b className="error">{error}</b> : null} {error.length > 0 ? <b className="error">{error}</b> : null}
<FontAwesomeIcon icon={faPaperclip} size="xl" onClick={(e) => attachFile()} /> <FontAwesomeIcon icon={faPaperclip} size="xl" onClick={(e) => attachFile()} />
</div> </div>
<div className="btn" onClick={() => sendNote()}>Send</div> <button type="button" className="btn" onClick={onSubmit}>
{replyTo ? 'Reply' : 'Send'}
</button>
</div> </div>
)} )}
</div> </div>