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