Skip to content

Commit 7935f25

Browse files
committed
clear dropdown when value is empty
1 parent 713b23a commit 7935f25

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

dist/vue-typed-ui.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,9 +1558,13 @@ var Dropdown = function (_DropdownBase2) {
15581558
}, {
15591559
key: 'valueChanged',
15601560
value: function valueChanged(val) {
1561-
if (this.multiple === true && this.selectedItems.toString() != val.toString()) {
1562-
this.sui('set exactly', val);
1563-
} else this.sui('set selected', val);
1561+
if (val === null || val === undefined) {
1562+
this.sui('clear');
1563+
} else {
1564+
if (this.multiple === true && this.selectedItems.toString() != val.toString()) {
1565+
this.sui('set exactly', val);
1566+
} else this.sui('set selected', val);
1567+
}
15641568
}
15651569
}, {
15661570
key: 'sui',

src/components/form-inputs/dropdown/index.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ export class Dropdown extends _DropdownBase {
5959
self.selectedItems.splice(self.selectedItems.indexOf(val), 1);
6060
}
6161
});
62-
62+
6363

6464
// make up data validate attr
65-
Util.setDataValidateAttr(this,$(this.$el).find('input'))
65+
Util.setDataValidateAttr(this, $(this.$el).find('input'))
6666

6767
// assign selected values
6868
this.valueChanged(this.value)
@@ -71,11 +71,14 @@ export class Dropdown extends _DropdownBase {
7171

7272
@Watch('value')
7373
valueChanged(val) {
74-
75-
if (this.multiple === true && this.selectedItems.toString() != val.toString()) {
76-
this.sui('set exactly', val);
77-
} else
78-
this.sui('set selected', val);
74+
if (val === null || val === undefined) {
75+
this.sui('clear')
76+
} else {
77+
if (this.multiple === true && this.selectedItems.toString() != val.toString()) {
78+
this.sui('set exactly', val);
79+
} else
80+
this.sui('set selected', val);
81+
}
7982
}
8083

8184
sui(arg1?, arg2?) {

0 commit comments

Comments
 (0)