Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion input/combo2/combo.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ Vue.component("n-input-combo2", {
this.showValues = true;
}
},
clearKeyValue: function() {
this.keyValue = null
},
initializeKeyValue: function() {
// if you have no key value yet, we just take the first one
if (this.keyValue == null) {
Expand All @@ -324,7 +327,11 @@ Vue.component("n-input-combo2", {
moveKeyValue: function(amount) {
// only relevant if you can see something
this.showValues = true;
this.initializeKeyValue();
if(this.keyValue === null) {
this.initializeKeyValue();
amount = 0; // we just initialised, don't change the index again
}

if (this.keyValue != null) {
var index = this.potentialValues.indexOf(this.keyValue);
index += amount;
Expand Down Expand Up @@ -558,6 +565,7 @@ Vue.component("n-input-combo2", {
},
toggle: function(entry) {
var index = this.rawValues.indexOf(entry);
// this entry was not selected yet
if (index < 0) {
if (!this.multiple) {
this.rawValues.splice(0);
Expand All @@ -568,15 +576,24 @@ Vue.component("n-input-combo2", {
this.showValues = false;
}
}
// this entry was already selected
else {
// we only want to allow deselection if you have at least one other value or it can be reset to nill
if (this.rawValues.length >= 2 || this.nillable) {
this.rawValues.splice(index, 1);
}

// clear the search input when (de)selecting an option
this.search = "";
}
}
},
watch: {
showValues: function(showValues) {
if (showValues === false) {
this.clearKeyValue();
}
},
calculating: function(newValue) {
if (!newValue && !this.initialized) {
if (this.value != null) {
Expand Down