diff --git a/server/public/home.html b/server/public/home.html index 81e42c7..86e206a 100644 --- a/server/public/home.html +++ b/server/public/home.html @@ -3481,7 +3481,11 @@ async function openConvo(kind,id){ el.ondrop=(e)=>{ const f=e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files[0]; if(f){ e.preventDefault(); el.classList.remove('drag-over'); uploadFile(f); } }; const back=document.getElementById('convoBack'); if(back) back.onclick=showWelcome; const form=document.getElementById('composer'); if(form) form.addEventListener('submit',(e)=>{ e.preventDefault(); sendMessage(); }); - clearReply(); cancelEdit(); hideAttach(); + // #14 ROOT CAUSE: do NOT call cancelEdit() here. It runs _restoreDraftAfterEdit → setDraft(selected,'') which + // WIPED the just-opened chat's draft (and blanked the composer) BEFORE the restore below could read it — the + // draft never survived reopening a chat. Edit state is already reset at the top (editTarget=null, + // _editSavedDraft=''), and the composer/edit bar are fresh from the shell rebuild, so nothing else is needed. + clearReply(); hideAttach(); const ab2=document.getElementById('attachBtn'); const apop=document.getElementById('attachPop'); if(ab2&&apop) ab2.onclick=(e)=>{ e.stopPropagation(); apop.style.display = apop.style.display==='none' ? 'flex' : 'none'; }; // show a composer-anchored menu instead of firing the generic mid-screen OS chooser straight away if(apop) apop.querySelectorAll('.attach-opt').forEach(b=>b.onclick=(e)=>{ e.stopPropagation(); apop.style.display='none'; const src=b.dataset.src; const inp = src==='photo'?document.getElementById('fileInputImg') : src==='camera'?document.getElementById('fileInputCam') : document.getElementById('fileInput'); if(inp) inp.click(); }); // Photos → gallery, Camera → capture, Document → any file