indrimuska / angular-selector

A native AngularJS directive that transform a simple <select> box into a full html select with typeahead.
http://indrimuska.github.io/angular-selector
MIT License
96 stars 36 forks source link

Typing and selecting an option with remote fetching causes invalid values #57

Open indrimuska opened 8 years ago

indrimuska commented 8 years ago

Plunker

http://plnkr.co/edit/CGY47bqX0dLnFkrVY3aB?p=preview

Scenario

ssotomayor commented 8 years ago

@indrimuska This has another issue as well. Selected options are removed after fetching in a multi selector.

Same scenario. Same plunker.

Steps to reproduce the issue

  1. Click the selector
  2. Select 3 options, say, Afghanistan - Aland Islands - Albania
  3. Type "Bra" to get "Brazil"
  4. Select "Brazil".
matt212 commented 7 years ago

Hi guys , Any update on this issue , kinda critical issue if some one points to me to right direction i might able to solve it !

ssotomayor commented 7 years ago

@matt212 Try my fork.

The problem was here:

            scope.updateSelected = function () {
                if (!scope.multiple) scope.selectedValues = (scope.options || []).filter(function (option) { return scope.optionEquals(option); }).slice(0, 1);
                else {
                    var val;
                    val = (scope.value || []).map(function (value) {
                        return filter(scope.options.concat(allOptions), function (option) {
                            return scope.optionEquals(option, value);
                        })[0];
                    }).filter(function (value) { return angular.isDefined(value); }).slice(0, scope.limit);
                    scope.selectedValues = val;
                }
            };

Options were being filtered after fetching again. I'm storing the options being fetched in my fork, had no time to implement a better solution att.

matt212 commented 7 years ago

Hi @ssotomayor , you are life saver ! thanks for insight and patch !

matt212 commented 7 years ago

How can i add values using create feature not from user input but from angularjs file. for eg :- instance of "selector" ,create (json object) and it should added to multiselect Any suggestions ? `

jeeyyy commented 6 years ago

This is fixed in a high performance variant/fork of the same component: https://github.com/jkodu/angular-selector-on-steroids

Refer enhanced example page - https://jkodu.github.io/angular-selector-on-steroids/ (allow unsafe scripts).

ssotomayor commented 6 years ago

@jkodu oh wow, did you fix the remote fetching issue mentioned above? Can't get the options to load up on your example page.

jeeyyy commented 6 years ago

Have you allowed unsafe scripts along the prompt on the address bar?

jeeyyy commented 6 years ago

@ssotomayor see comment above.