Browse Source

fix: autoComplete placeholder not hide #1506

pull/1794/head^2
tanjinzhou 5 years ago
parent
commit
9723a6253e
  1. 2
      components/auto-complete/InputElement.jsx
  2. 3
      components/auto-complete/index.jsx
  3. 4
      components/input/Input.jsx
  4. 1
      components/input/TextArea.jsx
  5. 4
      components/input/inputProps.js
  6. 19
      components/vc-select/Select.jsx

2
components/auto-complete/InputElement.jsx

@ -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];

3
components/auto-complete/index.jsx

@ -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>;
},

4
components/input/Input.jsx

@ -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 = {

1
components/input/TextArea.jsx

@ -155,6 +155,7 @@ export default {
'type',
'value',
'defaultValue',
'lazy',
]);
const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('input', customizePrefixCls);

4
components/input/inputProps.js

@ -33,4 +33,8 @@ export default {
spellCheck: Boolean,
autoFocus: Boolean,
allowClear: Boolean,
lazy: {
default: true,
type: Boolean,
},
};

19
components/vc-select/Select.jsx

@ -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…
Cancel
Save