correct issue with modal tag management submit function.

This commit is contained in:
Bryan Van Deusen
2026-01-18 12:32:05 -05:00
parent 21168117c1
commit 4c56b73bc9
+13 -10
View File
@@ -159,6 +159,16 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
// Shared function to submit a tag (avoids page refresh issues with form dispatch)
async function submitTag() {
const id = getEditorImageId();
const name = (tagInput?.value || '').trim();
if (!id || !name) return;
hideAutocomplete();
await addTag(id, name);
if (tagInput) tagInput.value = '';
}
if (tagInput) {
// Show autocomplete on focus
tagInput.addEventListener('focus', () => {
@@ -196,8 +206,7 @@ document.addEventListener('DOMContentLoaded', () => {
const selected = autocompleteItems[autocompleteSelectedIndex];
if (selected) {
tagInput.value = selected.name;
hideAutocomplete();
tagForm.dispatchEvent(new Event('submit'));
submitTag();
}
} else if (e.key === 'Escape') {
hideAutocomplete();
@@ -213,8 +222,7 @@ document.addEventListener('DOMContentLoaded', () => {
const name = item.dataset.name;
if (tagInput && name) {
tagInput.value = name;
hideAutocomplete();
tagForm.dispatchEvent(new Event('submit'));
submitTag();
}
});
}
@@ -222,12 +230,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (tagForm) {
tagForm.addEventListener('submit', async (e) => {
e.preventDefault();
const id = getEditorImageId();
const name = (tagInput.value || '').trim();
if (!id || !name) return;
hideAutocomplete();
await addTag(id, name);
tagInput.value = '';
await submitTag();
});
}
if (tagList) {