Skip to content

Commit 9723a62

Browse files
committed
fix: autoComplete placeholder not hide #1506
1 parent 197cad6 commit 9723a62

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

Diff for: components/auto-complete/InputElement.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default {
3030
},
3131

3232
render() {
33-
const { $slots = {}, $listeners = {}, $props = {}, $attrs = {} } = this;
33+
const { $slots = {}, $listeners = {}, $attrs = {} } = this;
3434
const props = getOptionProps(this);
3535
const value = props.value === undefined ? '' : props.value;
3636
const children = $slots.default[0];

Diff for: components/auto-complete/index.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ const AutoComplete = {
6969
savePopupRef(ref) {
7070
this.popupRef = ref;
7171
},
72+
7273
getInputElement() {
7374
const { $slots } = this;
7475
const children = filterEmpty($slots.default);
75-
const element = children.length ? children[0] : <Input />;
76+
const element = children.length ? children[0] : <Input lazy={false} />;
7677
return <InputElement>{element}</InputElement>;
7778
},
7879

Diff for: components/input/Input.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import TextArea from './TextArea';
33
import omit from 'omit.js';
44
import inputProps from './inputProps';
55
import { hasProp, getComponentFromProp } from '../_util/props-util';
6-
import { isIE, isIE9 } from '../_util/env';
76
import { ConfigConsumerProps } from '../config-provider';
87
import Icon from '../icon';
98

@@ -122,7 +121,7 @@ export default {
122121

123122
handleChange(e) {
124123
const { value, composing } = e.target;
125-
if (composing || this.stateValue === value) return;
124+
if (composing && this.lazy) return;
126125
this.setValue(value, e);
127126
},
128127

@@ -233,6 +232,7 @@ export default {
233232
'allowClear',
234233
'value',
235234
'defaultValue',
235+
'lazy',
236236
]);
237237
const { stateValue, getInputClassName, handleKeyDown, handleChange, $listeners } = this;
238238
const inputProps = {

Diff for: components/input/TextArea.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export default {
155155
'type',
156156
'value',
157157
'defaultValue',
158+
'lazy',
158159
]);
159160
const getPrefixCls = this.configProvider.getPrefixCls;
160161
const prefixCls = getPrefixCls('input', customizePrefixCls);

Diff for: components/input/inputProps.js

+4
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ export default {
3333
spellCheck: Boolean,
3434
autoFocus: Boolean,
3535
allowClear: Boolean,
36+
lazy: {
37+
default: true,
38+
type: Boolean,
39+
},
3640
};

Diff for: components/vc-select/Select.jsx

+5-14
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ const Select = {
622622
if (value.length) {
623623
hidden = true;
624624
}
625-
if (isCombobox(props) && value.length === 1 && (state._value && !state._value[0])) {
625+
if (!state._mirrorInputValue && isCombobox(props) && value.length === 1 && (state._value && !state._value[0])) {
626626
hidden = false;
627627
}
628628
const placeholder = props.placeholder;
@@ -744,19 +744,7 @@ const Select = {
744744
const props = this.$props;
745745
const { _inputValue: inputValue, _mirrorInputValue } = this.$data;
746746
const attrs = getAttrs(this);
747-
const defaultInput = (
748-
<input
749-
{...{
750-
directives: [
751-
{
752-
name: 'ant-input',
753-
},
754-
],
755-
}}
756-
id={attrs.id}
757-
autoComplete="off"
758-
/>
759-
);
747+
const defaultInput = <input id={attrs.id} autoComplete="off" />;
760748

761749
const inputElement = props.getInputElement ? props.getInputElement() : defaultInput;
762750
const inputCls = classnames(getClass(inputElement), {
@@ -787,6 +775,9 @@ const Select = {
787775
name: 'ant-ref',
788776
value: this.saveInputRef,
789777
},
778+
{
779+
name: 'ant-input',
780+
},
790781
],
791782
on: {
792783
input: this.onInputChange,

0 commit comments

Comments
 (0)