diff --git a/components/lib/cascadeselect/CascadeSelect.vue b/components/lib/cascadeselect/CascadeSelect.vue index cf81a3b4d..65f9933b1 100644 --- a/components/lib/cascadeselect/CascadeSelect.vue +++ b/components/lib/cascadeselect/CascadeSelect.vue @@ -283,13 +283,24 @@ export default { const { index, level, parentKey, children } = processedOption; const grouped = ObjectUtils.isNotEmpty(children); + const root = ObjectUtils.isEmpty(processedOption.parent); + const selected = this.isSelected(processedOption); - const activeOptionPath = this.activeOptionPath.filter((p) => p.parentKey !== parentKey); + if (selected) { + const { index, key, level, parentKey } = processedOption; - activeOptionPath.push(processedOption); + this.focusedOptionInfo = { index, level, parentKey }; + this.activeOptionPath = this.activeOptionPath.filter((p) => key !== p.key && key.startsWith(p.key)); - this.focusedOptionInfo = { index, level, parentKey }; - this.activeOptionPath = activeOptionPath; + this.dirty = !root; + } else { + const activeOptionPath = this.activeOptionPath.filter((p) => p.parentKey !== parentKey); + + activeOptionPath.push(processedOption); + + this.focusedOptionInfo = { index, level, parentKey }; + this.activeOptionPath = activeOptionPath; + } grouped ? this.onOptionGroupSelect(originalEvent, processedOption) : this.onOptionSelect(originalEvent, processedOption, isHide); isFocus && DomHandler.focus(this.$refs.focusInput);