web: restore ↓-to-cancel an unedited ↑-to-edit (#46)
The handler from #37 (↓ on an unchanged ↑-to-edit drops back to a normal empty composer) was silently lost — most likely when #39's typeahead block rebased over the same spot in the composer keydown handler. Re-add it after the ↑-to-edit block; the typeahead early-returns still claim ArrowDown first when the autocomplete popup is open, so they don't conflict.
Co-authored-by: Claude <noreply@anthropic.com>
1 file changed,
+10
−0
web/static/chat.js+10 −0
diff --git a/web/static/chat.js b/web/static/chat.js| index c2140f5..0c8dd0c 100644 |
| --- a/web/static/chat.js |
| +++ b/web/static/chat.js |
| @@ -746,6 +746,16 @@ function renderApp() { |
| startEdit(id); |
| } |
| } |
| + // ↓ undoes an accidental ↑-to-edit: only when nothing was typed (still the |
| + // original message) and there's no line below the cursor to navigate to. |
| + if (e.key === "ArrowDown" && editing != null) { |
| + const original = msgData[editing]?.data?.text ?? ""; |
| + const afterCursor = text.value.slice(text.selectionEnd); |
| + if (text.value === original && !afterCursor.includes("\n")) { |
| + e.preventDefault(); |
| + cancelEdit(); |
| + } |
| + } |
| }); |
| // Caret moves (click / arrows) can enter or leave a token too — re-check. |
| text.addEventListener("keyup", (e) => { |