fix: autoComplete placeholder not hide #1506
parent
197cad6c5f
commit
9723a6253e
|
@ -30,7 +30,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { $slots = {}, $listeners = {}, $props = {}, $attrs = {} } = this;
|
const { $slots = {}, $listeners = {}, $attrs = {} } = this;
|
||||||
const props = getOptionProps(this);
|
const props = getOptionProps(this);
|
||||||
const value = props.value === undefined ? '' : props.value;
|
const value = props.value === undefined ? '' : props.value;
|
||||||
const children = $slots.default[0];
|
const children = $slots.default[0];
|
||||||
|
|
|
@ -69,10 +69,11 @@ const AutoComplete = {
|
||||||
savePopupRef(ref) {
|
savePopupRef(ref) {
|
||||||
this.popupRef = ref;
|
this.popupRef = ref;
|
||||||
},
|
},
|
||||||
|
|
||||||
getInputElement() {
|
getInputElement() {
|
||||||
const { $slots } = this;
|
const { $slots } = this;
|
||||||
const children = filterEmpty($slots.default);
|
const children = filterEmpty($slots.default);
|
||||||
const element = children.length ? children[0] : <Input />;
|
const element = children.length ? children[0] : <Input lazy={false} />;
|
||||||
return <InputElement>{element}</InputElement>;
|
return <InputElement>{element}</InputElement>;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ import TextArea from './TextArea';
|
||||||
import omit from 'omit.js';
|
import omit from 'omit.js';
|
||||||
import inputProps from './inputProps';
|
import inputProps from './inputProps';
|
||||||
import { hasProp, getComponentFromProp } from '../_util/props-util';
|
import { hasProp, getComponentFromProp } from '../_util/props-util';
|
||||||
import { isIE, isIE9 } from '../_util/env';
|
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
import Icon from '../icon';
|
import Icon from '../icon';
|
||||||
|
|
||||||
|
@ -122,7 +121,7 @@ export default {
|
||||||
|
|
||||||
handleChange(e) {
|
handleChange(e) {
|
||||||
const { value, composing } = e.target;
|
const { value, composing } = e.target;
|
||||||
if (composing || this.stateValue === value) return;
|
if (composing && this.lazy) return;
|
||||||
this.setValue(value, e);
|
this.setValue(value, e);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -233,6 +232,7 @@ export default {
|
||||||
'allowClear',
|
'allowClear',
|
||||||
'value',
|
'value',
|
||||||
'defaultValue',
|
'defaultValue',
|
||||||
|
'lazy',
|
||||||
]);
|
]);
|
||||||
const { stateValue, getInputClassName, handleKeyDown, handleChange, $listeners } = this;
|
const { stateValue, getInputClassName, handleKeyDown, handleChange, $listeners } = this;
|
||||||
const inputProps = {
|
const inputProps = {
|
||||||
|
|
|
@ -155,6 +155,7 @@ export default {
|
||||||
'type',
|
'type',
|
||||||
'value',
|
'value',
|
||||||
'defaultValue',
|
'defaultValue',
|
||||||
|
'lazy',
|
||||||
]);
|
]);
|
||||||
const getPrefixCls = this.configProvider.getPrefixCls;
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
||||||
const prefixCls = getPrefixCls('input', customizePrefixCls);
|
const prefixCls = getPrefixCls('input', customizePrefixCls);
|
||||||
|
|
|
@ -33,4 +33,8 @@ export default {
|
||||||
spellCheck: Boolean,
|
spellCheck: Boolean,
|
||||||
autoFocus: Boolean,
|
autoFocus: Boolean,
|
||||||
allowClear: Boolean,
|
allowClear: Boolean,
|
||||||
|
lazy: {
|
||||||
|
default: true,
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -622,7 +622,7 @@ const Select = {
|
||||||
if (value.length) {
|
if (value.length) {
|
||||||
hidden = true;
|
hidden = true;
|
||||||
}
|
}
|
||||||
if (isCombobox(props) && value.length === 1 && (state._value && !state._value[0])) {
|
if (!state._mirrorInputValue && isCombobox(props) && value.length === 1 && (state._value && !state._value[0])) {
|
||||||
hidden = false;
|
hidden = false;
|
||||||
}
|
}
|
||||||
const placeholder = props.placeholder;
|
const placeholder = props.placeholder;
|
||||||
|
@ -744,19 +744,7 @@ const Select = {
|
||||||
const props = this.$props;
|
const props = this.$props;
|
||||||
const { _inputValue: inputValue, _mirrorInputValue } = this.$data;
|
const { _inputValue: inputValue, _mirrorInputValue } = this.$data;
|
||||||
const attrs = getAttrs(this);
|
const attrs = getAttrs(this);
|
||||||
const defaultInput = (
|
const defaultInput = <input id={attrs.id} autoComplete="off" />;
|
||||||
<input
|
|
||||||
{...{
|
|
||||||
directives: [
|
|
||||||
{
|
|
||||||
name: 'ant-input',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}}
|
|
||||||
id={attrs.id}
|
|
||||||
autoComplete="off"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
const inputElement = props.getInputElement ? props.getInputElement() : defaultInput;
|
const inputElement = props.getInputElement ? props.getInputElement() : defaultInput;
|
||||||
const inputCls = classnames(getClass(inputElement), {
|
const inputCls = classnames(getClass(inputElement), {
|
||||||
|
@ -787,6 +775,9 @@ const Select = {
|
||||||
name: 'ant-ref',
|
name: 'ant-ref',
|
||||||
value: this.saveInputRef,
|
value: this.saveInputRef,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'ant-input',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
on: {
|
on: {
|
||||||
input: this.onInputChange,
|
input: this.onInputChange,
|
||||||
|
|
Loading…
Reference in New Issue