angular-selectize
angular-selectize copied to clipboard
All options are treated as user options
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.
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.
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.
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.
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.