diff --git a/app/components/tag_list_input_component/tag_list_input_controller.js b/app/components/tag_list_input_component/tag_list_input_controller.js index ccc4be5f95..094e3cca4a 100644 --- a/app/components/tag_list_input_component/tag_list_input_controller.js +++ b/app/components/tag_list_input_component/tag_list_input_controller.js @@ -8,12 +8,12 @@ export default class extends Controller { // prevent hotkey form submitting the form (default action for "enter" key) event.preventDefault(); - // Check if tag already exist - const newTagName = this.newTagTarget.value.trim(); + const newTagName = this.newTagTarget.value.trim().replaceAll(" ", "-"); if (newTagName.length == 0) { return; } + // Check if tag already exist const tags = this.tagListTarget.value.split(","); const index = tags.indexOf(newTagName); if (index != -1) { diff --git a/spec/javascripts/stimulus/tag_list_input_controller_test.js b/spec/javascripts/stimulus/tag_list_input_controller_test.js index 1f72bcf22c..91ed014be9 100644 --- a/spec/javascripts/stimulus/tag_list_input_controller_test.js +++ b/spec/javascripts/stimulus/tag_list_input_controller_test.js @@ -16,7 +16,7 @@ describe("TagListInputController", () => { document.body.innerHTML = `