diff --git a/facilities.html b/facilities.html index 430b3da..5a22071 100644 --- a/facilities.html +++ b/facilities.html @@ -256,7 +256,7 @@
- +
diff --git a/js/facilities_script.js b/js/facilities_script.js index 531f049..64a13ab 100644 --- a/js/facilities_script.js +++ b/js/facilities_script.js @@ -485,6 +485,19 @@ document.addEventListener('DOMContentLoaded', () => { }); } + function commitContributorInput() { + const contributorInput = document.getElementById('editor-contributor-input'); + const value = contributorInput.value.trim(); + + if (value && !editorContributors.includes(value)) { + editorContributors.push(value); + renderContributorTags(); + updatePreview(); + } + + contributorInput.value = ''; + } + document.getElementById('editor-contributors-tags').addEventListener('click', (e) => { const removeBtn = e.target.closest('.editor-tag-remove'); if (removeBtn) { @@ -496,16 +509,18 @@ document.addEventListener('DOMContentLoaded', () => { }); document.getElementById('editor-contributor-input').addEventListener('keydown', (e) => { - if (e.key === 'Enter') { - e.preventDefault(); - const val = e.target.value.trim(); - if (val && !editorContributors.includes(val)) { - editorContributors.push(val); - renderContributorTags(); - updatePreview(); - } - e.target.value = ''; + if (e.isComposing) { + return; } + + if (e.key === 'Enter' || e.key === ' ' || e.code === 'Space') { + e.preventDefault(); + commitContributorInput(); + } + }); + + document.getElementById('editor-contributor-input').addEventListener('blur', () => { + commitContributorInput(); }); // Click on wrapper focuses input