Fix thread search suggestions: navigate on click, fix duplicate ID

- Add explicit click handler on suggestions so clicking navigates
  to the existing thread instead of interacting with the form
- Fix duplicate id="thread_title_input" in forms.j2 edit macro
  (renamed to edit_title_input to avoid conflict with create form)
This commit is contained in:
russell@unturf.com 2026-02-02 08:13:05 -05:00
parent c038b649b2
commit b6739fff70
2 changed files with 11 additions and 1 deletions

View file

@ -147,6 +147,16 @@ function initThreadTitleTypeahead() {
}, 400);
});
// Clicking a suggestion navigates to that thread.
suggestionsDiv.addEventListener('click', function(e) {
var link = e.target.closest('.suggestion-item');
if (link && link.href) {
e.preventDefault();
e.stopPropagation();
window.location.href = link.href;
}
});
// Hide suggestions when clicking outside.
document.addEventListener('click', function(e) {
if (e.target !== titleInput && !suggestionsDiv.contains(e.target)) {

View file

@ -49,7 +49,7 @@
{% if node.title %}
<input
name = "thread_title"
id = "thread_title_input"
id = "edit_title_input"
class = "common-text-input"
value = "{{ node.title }}"
placeholder = "Descriptive title"