Merge pull request #3576 from SergioCrisostomo/refactor-select
Select related fixes
This commit is contained in:
commit
d4f39edc35
2 changed files with 18 additions and 16 deletions
|
@ -207,7 +207,7 @@
|
||||||
|
|
||||||
// set the initial values if there are any
|
// set the initial values if there are any
|
||||||
if (this.values.length > 0 && !this.remote && this.selectOptions.length > 0){
|
if (this.values.length > 0 && !this.remote && this.selectOptions.length > 0){
|
||||||
this.values = this.values.map(this.getOptionData);
|
this.values = this.values.map(this.getOptionData).filter(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.values.length > 0 && this.selectOptions.length === 0){
|
if (this.values.length > 0 && this.selectOptions.length === 0){
|
||||||
|
@ -307,7 +307,7 @@
|
||||||
const slotOptions = (this.slotOptions || []);
|
const slotOptions = (this.slotOptions || []);
|
||||||
let optionCounter = -1;
|
let optionCounter = -1;
|
||||||
const currentIndex = this.focusIndex;
|
const currentIndex = this.focusIndex;
|
||||||
const selectedValues = this.values.map(({value}) => value);
|
const selectedValues = this.values.filter(Boolean).map(({value}) => value);
|
||||||
if (this.autoComplete) {
|
if (this.autoComplete) {
|
||||||
const copyChildren = (node, fn) => {
|
const copyChildren = (node, fn) => {
|
||||||
return {
|
return {
|
||||||
|
@ -398,7 +398,7 @@
|
||||||
const {multiple, value} = this;
|
const {multiple, value} = this;
|
||||||
let initialValue = Array.isArray(value) ? value : [value];
|
let initialValue = Array.isArray(value) ? value : [value];
|
||||||
if (!multiple && (typeof initialValue[0] === 'undefined' || String(initialValue[0]).trim() === '')) initialValue = [];
|
if (!multiple && (typeof initialValue[0] === 'undefined' || String(initialValue[0]).trim() === '')) initialValue = [];
|
||||||
return initialValue;
|
return initialValue.filter(Boolean);
|
||||||
},
|
},
|
||||||
processOption(option, values, isFocused){
|
processOption(option, values, isFocused){
|
||||||
if (!option.componentOptions) return option;
|
if (!option.componentOptions) return option;
|
||||||
|
@ -482,6 +482,7 @@
|
||||||
|
|
||||||
// Esc slide-up
|
// Esc slide-up
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
|
e.stopPropagation();
|
||||||
this.hideMenu();
|
this.hideMenu();
|
||||||
}
|
}
|
||||||
// next
|
// next
|
||||||
|
@ -493,7 +494,8 @@
|
||||||
this.navigateOptions(1);
|
this.navigateOptions(1);
|
||||||
}
|
}
|
||||||
// enter
|
// enter
|
||||||
if (e.key === 'Enter' && this.focusIndex > -1) {
|
if (e.key === 'Enter') {
|
||||||
|
if (this.focusIndex === -1) return this.hideMenu();
|
||||||
const optionComponent = this.flatOptions[this.focusIndex];
|
const optionComponent = this.flatOptions[this.focusIndex];
|
||||||
const option = this.getOptionData(optionComponent.componentOptions.propsData.value);
|
const option = this.getOptionData(optionComponent.componentOptions.propsData.value);
|
||||||
this.onOptionClick(option);
|
this.onOptionClick(option);
|
||||||
|
@ -580,7 +582,7 @@
|
||||||
|
|
||||||
if (value === '') this.values = [];
|
if (value === '') this.values = [];
|
||||||
else if (JSON.stringify(value) !== JSON.stringify(publicValue)) {
|
else if (JSON.stringify(value) !== JSON.stringify(publicValue)) {
|
||||||
this.$nextTick(() => this.values = getInitialValue().map(getOptionData));
|
this.$nextTick(() => this.values = getInitialValue().map(getOptionData).filter(Boolean));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
values(now, before){
|
values(now, before){
|
||||||
|
@ -659,7 +661,7 @@
|
||||||
},
|
},
|
||||||
selectOptions(){
|
selectOptions(){
|
||||||
if (this.hasExpectedValue){
|
if (this.hasExpectedValue){
|
||||||
this.values = this.values.map(this.getOptionData);
|
this.values = this.values.map(this.getOptionData).filter(Boolean);
|
||||||
this.hasExpectedValue = false;
|
this.hasExpectedValue = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ const lang = {
|
||||||
select: {
|
select: {
|
||||||
placeholder: 'Välj',
|
placeholder: 'Välj',
|
||||||
noMatch: 'Ingen träff',
|
noMatch: 'Ingen träff',
|
||||||
loading: 'Ladar'
|
loading: 'Laddar'
|
||||||
},
|
},
|
||||||
table: {
|
table: {
|
||||||
noDataText: 'Ingen data',
|
noDataText: 'Ingen data',
|
||||||
|
|
Loading…
Add table
Reference in a new issue