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

All options are treated as user options

Open PhiLhoSoft opened this issue 10 years ago • 4 comments

This wrapper takes either the value of the options attribute, or the options configuration (or the ngModel options otherwise) and adds them to Selectize via the addOption() API.

This is not a good behavior: Selectize itself treats the options configuration in a special way, using registerOption() instead, so these are base options that cannot be deleted. Only the options really added by the user can be deleted, the others are just unselected and added back to the option list.

angular-selectize should use registerOption() too to initialize the component.

PhiLhoSoft avatar Apr 29 '15 12:04 PhiLhoSoft

I have made a fix for this issue, it is in my fork, but to make a clean pull request, it seems the previous pull request must be merged. Maybe I should have made parallel branches, but somehow these fixes are more or less interdependent.

PhiLhoSoft avatar Aug 06 '15 10:08 PhiLhoSoft

I don't see how this distinction can be made by the wrapper. How does it know which options in $scope.options are from the user? If $scope.options becomes [] I think the wrapper should delete all options.

machineboy2045 avatar Sep 23 '15 14:09 machineboy2045

The wrapper doesn't need to make a distinction. It adds all options in $scope.options via registerOptions, and lets Selectize to add user options via its own addOption, ie. as user options. Ie. the former are "native" options (eg. coming from the server, or hard-coded) and the latter are really the new ones entered manually. The distinction allows to put back native options to the drop-down if removed from the selection, while user-entered options doesn't go there. My latest pull request managed proper deletion of options.

PhiLhoSoft avatar Sep 24 '15 11:09 PhiLhoSoft

Honestly, this behavior is very annoying. I have another case where I really want to distinguish original options from typed ones! I will see if I can rework my PR to fit current v3 version.

PhiLhoSoft avatar Mar 02 '16 14:03 PhiLhoSoft