Cascader: hide label when user inputs (#11738)

* Cascader: hide label when user input

* Cascader: update main.vue

* Update main.vue

* Cascader: not set readonly in IE
pull/11794/head
hetech 2018-06-28 19:05:26 +08:00 committed by 杨奕
parent ca567cc752
commit b4c84c509d
1 changed files with 13 additions and 3 deletions

View File

@ -19,12 +19,14 @@
> >
<el-input <el-input
ref="input" ref="input"
:readonly="!filterable" :readonly="readonly"
:placeholder="currentLabels.length ? undefined : placeholder" :placeholder="currentLabels.length ? undefined : placeholder"
v-model="inputValue" v-model="inputValue"
@input="debouncedInputChange" @input="debouncedInputChange"
@focus="handleFocus" @focus="handleFocus"
@blur="handleBlur" @blur="handleBlur"
@compositionstart.native="handleComposition"
@compositionend.native="handleComposition"
:validate-event="false" :validate-event="false"
:size="size" :size="size"
:disabled="cascaderDisabled" :disabled="cascaderDisabled"
@ -44,7 +46,7 @@
></i> ></i>
</template> </template>
</el-input> </el-input>
<span class="el-cascader__label" v-show="inputValue === ''"> <span class="el-cascader__label" v-show="inputValue === '' && !isOnComposition">
<template v-if="showAllLevels"> <template v-if="showAllLevels">
<template v-for="(label, index) in currentLabels"> <template v-for="(label, index) in currentLabels">
{{ label }} {{ label }}
@ -180,7 +182,8 @@ export default {
inputValue: '', inputValue: '',
flatOptions: null, flatOptions: null,
id: generateId(), id: generateId(),
needFocus: true needFocus: true,
isOnComposition: false
}; };
}, },
@ -217,6 +220,10 @@ export default {
}, },
cascaderDisabled() { cascaderDisabled() {
return this.disabled || (this.elForm || {}).disabled; return this.disabled || (this.elForm || {}).disabled;
},
readonly() {
const isIE = !this.$isServer && !isNaN(Number(document.documentMode));
return !this.filterable || (!isIE && !this.menuVisible);
} }
}, },
@ -409,6 +416,9 @@ export default {
}, },
handleBlur(event) { handleBlur(event) {
this.$emit('blur', event); this.$emit('blur', event);
},
handleComposition(event) {
this.isOnComposition = event.type !== 'compositionend';
} }
}, },