Refactor #6538
parent
34eeaedd56
commit
7b8d06c429
|
@ -320,7 +320,7 @@ export default {
|
||||||
this.focusedOptionInfo = { index, level, parentKey };
|
this.focusedOptionInfo = { index, level, parentKey };
|
||||||
this.activeOptionPath = activeOptionPath;
|
this.activeOptionPath = activeOptionPath;
|
||||||
},
|
},
|
||||||
onOptionClick(event) {
|
onOptionClick(event, preventSelection) {
|
||||||
const { originalEvent, processedOption, isFocus, isHide } = event;
|
const { originalEvent, processedOption, isFocus, isHide } = event;
|
||||||
const { index, key, level, parentKey } = processedOption;
|
const { index, key, level, parentKey } = processedOption;
|
||||||
const grouped = this.isProccessedOptionGroup(processedOption);
|
const grouped = this.isProccessedOptionGroup(processedOption);
|
||||||
|
@ -332,17 +332,21 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
if (grouped) {
|
if (grouped) {
|
||||||
this.onOptionChange(event);
|
this.onOptionChange(event);
|
||||||
|
this.onOptionGroupSelect(originalEvent, processedOption);
|
||||||
} else {
|
} else {
|
||||||
const activeOptionPath = this.activeOptionPath.filter((p) => p.parentKey !== parentKey);
|
const activeOptionPath = this.activeOptionPath.filter((p) => p.parentKey !== parentKey);
|
||||||
|
|
||||||
activeOptionPath.push(processedOption);
|
activeOptionPath.push(processedOption);
|
||||||
|
|
||||||
this.focusedOptionInfo = { index, level, parentKey };
|
this.focusedOptionInfo = { index, level, parentKey };
|
||||||
this.activeOptionPath = activeOptionPath;
|
|
||||||
|
if (!preventSelection || processedOption?.children.length !== 0) {
|
||||||
|
this.activeOptionPath = activeOptionPath;
|
||||||
|
this.onOptionSelect(originalEvent, processedOption, isHide);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
grouped ? this.onOptionGroupSelect(originalEvent, processedOption) : this.onOptionSelect(originalEvent, processedOption, isHide);
|
|
||||||
isFocus && focus(this.$refs.focusInput);
|
isFocus && focus(this.$refs.focusInput);
|
||||||
},
|
},
|
||||||
onOptionMouseEnter(event) {
|
onOptionMouseEnter(event) {
|
||||||
|
@ -405,7 +409,7 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
const optionIndex = this.focusedOptionInfo.index !== -1 ? this.findNextOptionIndex(this.focusedOptionInfo.index) : this.clicked ? this.findFirstOptionIndex() : this.findFirstFocusedOptionIndex();
|
const optionIndex = this.focusedOptionInfo.index !== -1 ? this.findNextOptionIndex(this.focusedOptionInfo.index) : this.clicked ? this.findFirstOptionIndex() : this.findFirstFocusedOptionIndex();
|
||||||
|
|
||||||
this.changeFocusedOptionIndex(event, optionIndex);
|
this.changeFocusedOptionIndex(event, optionIndex, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -424,7 +428,7 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
const optionIndex = this.focusedOptionInfo.index !== -1 ? this.findPrevOptionIndex(this.focusedOptionInfo.index) : this.clicked ? this.findLastOptionIndex() : this.findLastFocusedOptionIndex();
|
const optionIndex = this.focusedOptionInfo.index !== -1 ? this.findPrevOptionIndex(this.focusedOptionInfo.index) : this.clicked ? this.findLastOptionIndex() : this.findLastFocusedOptionIndex();
|
||||||
|
|
||||||
this.changeFocusedOptionIndex(event, optionIndex);
|
this.changeFocusedOptionIndex(event, optionIndex, true);
|
||||||
|
|
||||||
!this.overlayVisible && this.show();
|
!this.overlayVisible && this.show();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -491,7 +495,7 @@ export default {
|
||||||
const processedOption = this.visibleOptions[this.focusedOptionInfo.index];
|
const processedOption = this.visibleOptions[this.focusedOptionInfo.index];
|
||||||
const grouped = this.isProccessedOptionGroup(processedOption);
|
const grouped = this.isProccessedOptionGroup(processedOption);
|
||||||
|
|
||||||
this.onOptionChange({ originalEvent: event, processedOption });
|
this.onOptionClick({ originalEvent: event, processedOption }, false);
|
||||||
!grouped && this.hide();
|
!grouped && this.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -721,11 +725,15 @@ export default {
|
||||||
|
|
||||||
return matched;
|
return matched;
|
||||||
},
|
},
|
||||||
changeFocusedOptionIndex(event, index) {
|
changeFocusedOptionIndex(event, index, preventSelection) {
|
||||||
if (this.focusedOptionInfo.index !== index) {
|
if (this.focusedOptionInfo.index !== index) {
|
||||||
this.focusedOptionInfo.index = index;
|
this.focusedOptionInfo.index = index;
|
||||||
this.scrollInView();
|
this.scrollInView();
|
||||||
|
|
||||||
|
if (this.focusOnHover) {
|
||||||
|
this.onOptionClick({ originalEvent: event, processedOption: this.visibleOptions[index], isHide: false }, preventSelection);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.selectOnFocus) {
|
if (this.selectOnFocus) {
|
||||||
this.onOptionChange({ originalEvent: event, processedOption: this.visibleOptions[index], isHide: false });
|
this.onOptionChange({ originalEvent: event, processedOption: this.visibleOptions[index], isHide: false });
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,9 +136,6 @@ const theme = ({ dt }) => `
|
||||||
border: 0 none;
|
border: 0 none;
|
||||||
color: ${dt('cascadeselect.option.color')};
|
color: ${dt('cascadeselect.option.color')};
|
||||||
background: transparent;
|
background: transparent;
|
||||||
transition: background ${dt('cascadeselect.transition.duration')}, color ${dt('cascadeselect.transition.duration')}, border-color ${dt('cascadeselect.transition.duration')}, box-shadow ${dt(
|
|
||||||
'cascadeselect.transition.duration'
|
|
||||||
)}, outline-color ${dt('cascadeselect.transition.duration')};
|
|
||||||
border-radius: ${dt('cascadeselect.option.border.radius')};
|
border-radius: ${dt('cascadeselect.option.border.radius')};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,6 +180,9 @@ const theme = ({ dt }) => `
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: ${dt('cascadeselect.option.padding')};
|
padding: ${dt('cascadeselect.option.padding')};
|
||||||
border-radius: ${dt('cascadeselect.option.border.radius')};
|
border-radius: ${dt('cascadeselect.option.border.radius')};
|
||||||
|
transition: background ${dt('cascadeselect.transition.duration')}, color ${dt('cascadeselect.transition.duration')}, border-color ${dt('cascadeselect.transition.duration')}, box-shadow ${dt(
|
||||||
|
'cascadeselect.transition.duration'
|
||||||
|
)}, outline-color ${dt('cascadeselect.transition.duration')};
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-cascadeselect-group-icon {
|
.p-cascadeselect-group-icon {
|
||||||
|
|
Loading…
Reference in New Issue