angular-selector icon indicating copy to clipboard operation
angular-selector copied to clipboard

Typing and selecting an option with remote fetching causes invalid values

Open indrimuska opened this issue 9 years ago • 9 comments

Plunker

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

Scenario

  • Multiple select
  • Remote fetching
  • No remote validation

Steps to reproduce the issue

  1. type "f" in the input field
  2. press Enter

indrimuska avatar Jul 21 '16 12:07 indrimuska

@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".

ssotomayor avatar Nov 04 '16 15:11 ssotomayor

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 !

matt212 avatar Jan 03 '17 11:01 matt212

@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.

ssotomayor avatar Jan 03 '17 19:01 ssotomayor

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

matt212 avatar Jan 04 '17 06:01 matt212

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 ? `

matt212 avatar Jan 08 '17 18:01 matt212

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).

jeeyyy avatar Jan 29 '18 15:01 jeeyyy

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

ssotomayor avatar Jan 30 '18 15:01 ssotomayor

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

jeeyyy avatar Jan 30 '18 17:01 jeeyyy

@ssotomayor see comment above.

jeeyyy avatar Jan 30 '18 20:01 jeeyyy