Skip to content

Commit f22169f

Browse files
author
Ayman Jitan
authored
Remove empty item from multi-option type select (#16)
1 parent 99e02fa commit f22169f

File tree

7 files changed

+26
-10
lines changed

7 files changed

+26
-10
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-sc-select",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"homepage": "https://github.com/singlecomm/angular-sc-select",
55
"authors": [
66
"Matt Lewis"

dist/sc-select.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ return /******/ (function(modules) { // webpackBootstrap
183183
value: true
184184
});
185185

186-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
186+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
187187

188188
exports.default = scSelect;
189189

@@ -340,8 +340,16 @@ return /******/ (function(modules) { // webpackBootstrap
340340
});
341341
}
342342

343-
if (matchingItems.length === 0 && _typeof(ngModelCtrl.$viewValue) === 'object') {
344-
matchingItems = [ngModelCtrl.$viewValue];
343+
if (_typeof(ngModelCtrl.$viewValue) === 'object') {
344+
for (var i = 0; i < ngModelCtrl.$viewValue.length; i++) {
345+
if (!ngModelCtrl.$viewValue[i].id) {
346+
ngModelCtrl.$viewValue.splice(i--, 1);
347+
}
348+
}
349+
350+
if (!matchingItems.length && ngModelCtrl.$viewValue.length) {
351+
matchingItems = [ngModelCtrl.$viewValue];
352+
}
345353
}
346354

347355
if (vm.multiple) {

dist/sc-select.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/sc-select.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/sc-select.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-sc-select",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "An opinionated wrapper around the ui-select module",
55
"webpack": "src/module.js",
66
"browser": "dist/sc-select.js",

src/directives/scSelect.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,16 @@ export default function scSelect() {
183183
});
184184
}
185185

186-
if (matchingItems.length === 0 && typeof ngModelCtrl.$viewValue === 'object') {
187-
matchingItems = [ngModelCtrl.$viewValue];
186+
if (typeof ngModelCtrl.$viewValue === 'object') {
187+
for (var i = 0; i < ngModelCtrl.$viewValue.length; i++) {
188+
if (!ngModelCtrl.$viewValue[i].id) {
189+
ngModelCtrl.$viewValue.splice(i--, 1);
190+
}
191+
}
192+
193+
if (!matchingItems.length && ngModelCtrl.$viewValue.length) {
194+
matchingItems = [ngModelCtrl.$viewValue];
195+
}
188196
}
189197

190198
if (vm.multiple) {

0 commit comments

Comments
 (0)