diff --git a/static/app.js b/static/app.js
index 97f0ae77e..6bd19aea8 100644
--- a/static/app.js
+++ b/static/app.js
@@ -1689,12 +1689,20 @@ function initializeEventListeners() {
const newMemoryInput = el('new-memory-input');
if (newMemoryInput) {
- newMemoryInput.addEventListener('keypress', (e) => {
- if (e.key === 'Enter') {
+ // keydown, not the deprecated keypress: keypress is not guaranteed to
+ // fire for Enter everywhere, which left the Add Memory form with no
+ // working submit path (#5828).
+ newMemoryInput.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter' && !e.isComposing) {
+ e.preventDefault();
memoryModule.addNewMemory();
}
});
}
+ const newMemoryAddBtn = el('new-memory-add-btn');
+ if (newMemoryAddBtn) {
+ newMemoryAddBtn.addEventListener('click', () => memoryModule.addNewMemory());
+ }
// Voice recording is handled by the dual-purpose send/mic button (see below)
diff --git a/static/index.html b/static/index.html
index 8257660fe..7a053c05e 100644
--- a/static/index.html
+++ b/static/index.html
@@ -365,6 +365,7 @@
Add a memory — e.g. 'I prefer concise replies'
+
diff --git a/tests/test_memory_add_submit_regression.py b/tests/test_memory_add_submit_regression.py
new file mode 100644
index 000000000..450d63003
--- /dev/null
+++ b/tests/test_memory_add_submit_regression.py
@@ -0,0 +1,54 @@
+"""The Brain > Add Memory form must be submittable (#5828).
+
+The form previously had no submit button and relied on a deprecated
+``keypress`` listener for Enter, which is not guaranteed to fire on all
+platforms — leaving the form with no working submit path. Pins:
+
+- a visible, keyboard-accessible submit button next to the category select;
+- the button wired to ``memoryModule.addNewMemory()``;
+- Enter handled via ``keydown`` with ``preventDefault()`` (and no lingering
+ ``keypress`` handler on the input).
+"""
+from pathlib import Path
+
+APP_JS = Path("static/app.js")
+INDEX_HTML = Path("static/index.html")
+
+
+def _add_memory_row(html):
+ start = html.index('id="new-memory-input"')
+ end = html.index("
", html.index('id="new-memory-add-btn"', start))
+ return html[start:end]
+
+
+def test_add_memory_form_renders_a_submit_button():
+ html = INDEX_HTML.read_text()
+ row = _add_memory_row(html)
+
+ assert 'id="new-memory-category"' in row, "button must sit in the same row as the form fields"
+ btn_start = row.index('id="new-memory-add-btn"')
+ btn_tag = row[row.rindex("