Commit bdd95cf9 authored by hetech's avatar hetech Committed by 杨奕

Cascader: not focus when outside clicked (#11588)

parent e58cffaa
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<template v-if="showAllLevels"> <template v-if="showAllLevels">
<template v-for="(label, index) in currentLabels"> <template v-for="(label, index) in currentLabels">
{{ label }} {{ label }}
<span v-if="index < currentLabels.length - 1"> {{ separator }} </span> <span v-if="index < currentLabels.length - 1" :key="index"> {{ separator }} </span>
</template> </template>
</template> </template>
<template v-else> <template v-else>
...@@ -178,7 +178,9 @@ export default { ...@@ -178,7 +178,9 @@ export default {
menuVisible: false, menuVisible: false,
inputHover: false, inputHover: false,
inputValue: '', inputValue: '',
flatOptions: null flatOptions: null,
id: generateId(),
needFocus: true
}; };
}, },
...@@ -215,9 +217,6 @@ export default { ...@@ -215,9 +217,6 @@ export default {
}, },
cascaderDisabled() { cascaderDisabled() {
return this.disabled || (this.elForm || {}).disabled; return this.disabled || (this.elForm || {}).disabled;
},
id() {
return generateId();
} }
}, },
...@@ -280,7 +279,11 @@ export default { ...@@ -280,7 +279,11 @@ export default {
hideMenu() { hideMenu() {
this.inputValue = ''; this.inputValue = '';
this.menu.visible = false; this.menu.visible = false;
this.$refs.input.focus(); if (this.needFocus) {
this.$refs.input.focus();
} else {
this.needFocus = true;
}
}, },
handleActiveItemChange(value) { handleActiveItemChange(value) {
this.$nextTick(_ => { this.$nextTick(_ => {
...@@ -387,6 +390,9 @@ export default { ...@@ -387,6 +390,9 @@ export default {
this.handlePick([], true); this.handlePick([], true);
}, },
handleClickoutside() { handleClickoutside() {
if (this.menuVisible) {
this.needFocus = false;
}
this.menuVisible = false; this.menuVisible = false;
}, },
handleClick() { handleClick() {
......
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
changeOnSelect: false, changeOnSelect: false,
popperClass: '', popperClass: '',
hoverTimer: 0, hoverTimer: 0,
clicking: false clicking: false,
id: generateId()
}; };
}, },
...@@ -97,9 +98,6 @@ ...@@ -97,9 +98,6 @@
formatOptions(optionsCopy); formatOptions(optionsCopy);
return loadActiveOptions(optionsCopy); return loadActiveOptions(optionsCopy);
} }
},
id() {
return generateId();
} }
}, },
......
...@@ -66,16 +66,14 @@ ...@@ -66,16 +66,14 @@
menuItems: null, menuItems: null,
menuItemsArray: null, menuItemsArray: null,
dropdownElm: null, dropdownElm: null,
focusing: false focusing: false,
listId: `dropdown-menu-${generateId()}`
}; };
}, },
computed: { computed: {
dropdownSize() { dropdownSize() {
return this.size || (this.$ELEMENT || {}).size; return this.size || (this.$ELEMENT || {}).size;
},
listId() {
return `dropdown-menu-${generateId()}`;
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment