diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/tags/umbtagseditor.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/tags/umbtagseditor.directive.js index fbc237e3d3..8bad5ae8fd 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/tags/umbtagseditor.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/tags/umbtagseditor.directive.js @@ -34,6 +34,7 @@ vm.$onDestroy = onDestroy; vm.validateMandatory = validateMandatory; + vm.addTagOnEnter = addTagOnEnter; vm.addTag = addTag; vm.removeTag = removeTag; vm.showPrompt = showPrompt; @@ -203,6 +204,16 @@ } } + function addTagOnEnter(e) { + var code = e.keyCode || e.which; + if (code == 13) { //Enter keycode + if ($element.find('.tags-' + vm.htmlId).parent().find(".tt-menu .tt-cursor").length === 0) { + //this is required, otherwise the html form will attempt to submit. + e.preventDefault(); + addTag(); + } + } + } function addTag() { //ensure that we're not pressing the enter key whilst selecting a typeahead value from the drop down //we need to use jquery because typeahead duplicates the text box diff --git a/src/Umbraco.Web.UI.Client/src/views/components/tags/umb-tags-editor.html b/src/Umbraco.Web.UI.Client/src/views/components/tags/umb-tags-editor.html index 4921bee386..4f83e05c17 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/tags/umb-tags-editor.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/tags/umb-tags-editor.html @@ -24,6 +24,7 @@ id="{{vm.htmlId}}" class="typeahead tags-{{vm.htmlId}}" ng-model="vm.tagToAdd" + ng-keydown="vm.addTagOnEnter($event)" on-blur="vm.addTag()" localize="placeholder" placeholder="@placeholders_enterTags" />