angular-ui / ui-select

AngularJS-native version of Select2 and Selectize
MIT License
3.26k stars 1.82k forks source link

tagging is accepted only by pressing "Enter" key #2107

Open yogevge opened 6 years ago

yogevge commented 6 years ago
                        <ui-select ng-model="request.selectedFoo"
                                   theme="bootstrap"
                                   tagging-label=""
                                   tagging="addFoo">
                            <ui-select-match placeholder="--- Select Foo---">{{$select.selected.name}}</ui-select-match>
                            <ui-select-choices repeat="foo in foos | filter: $select.search">
                                <div ng-bind-html="foo.name | highlight: $select.search"></div>
                            </ui-select-choices>
                        </ui-select>

I have a problem where I can't accept tagging with "On blur" I saw some improvements for multiple but nothing for one choice.

I saw this directive: app.directive('tagOnBlur', function ($timeout) { return { require: 'uiSelect', link: function (scope, elm, attrs, ctrl) { ctrl.searchInput.on('blur', function () { if ((ctrl.items.length > 0 || ctrl.tagging.isActivated)) { $timeout(function () { ctrl.searchInput.triggerHandler('tagged'); var newItem = ctrl.search; if (ctrl.tagging.fct) { newItem = ctrl.tagging.fct(newItem); } if (newItem) ctrl.select(newItem, true); }); } }); } }; })

But it doesn't accept when I click on something from the list (regular option) is there an option to accept a tag with "on blur"?

pavanesh2009 commented 6 years ago

Duplicate #2133