fix: input clear not focus
parent
d58a0f21df
commit
cbef867da8
|
@ -1 +1 @@
|
|||
Subproject commit 2d8d146c97bb030ac9fe572741483db8f7436460
|
||||
Subproject commit e58ddcdb3436fbf430e69953053d73114ce6ce6b
|
|
@ -1,6 +1,6 @@
|
|||
import { inject } from 'vue';
|
||||
import PropTypes from '../_util/vue-types';
|
||||
import { filterEmpty, getSlot } from '../_util/props-util';
|
||||
import { getSlot } from '../_util/props-util';
|
||||
import { ConfigConsumerProps } from '../config-provider';
|
||||
|
||||
export default {
|
||||
|
@ -34,6 +34,6 @@ export default {
|
|||
},
|
||||
},
|
||||
render() {
|
||||
return <span class={this.classes}>{filterEmpty(getSlot(this))}</span>;
|
||||
return <span class={this.classes}>{getSlot(this)}</span>;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -114,14 +114,14 @@ export default {
|
|||
}
|
||||
if (!hasProp(this, 'value')) {
|
||||
this.stateValue = value;
|
||||
this.$nextTick(() => {
|
||||
callback && callback();
|
||||
});
|
||||
} else {
|
||||
this.$forceUpdate();
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
callback && callback();
|
||||
});
|
||||
},
|
||||
onChange(e) {
|
||||
triggerChange(e) {
|
||||
this.$emit('update:value', e.target.value);
|
||||
this.$emit('change', e);
|
||||
this.$emit('input', e);
|
||||
|
@ -130,11 +130,12 @@ export default {
|
|||
this.setValue('', () => {
|
||||
this.focus();
|
||||
});
|
||||
resolveOnChange(this.input, e, this.onChange);
|
||||
resolveOnChange(this.input, e, this.triggerChange);
|
||||
},
|
||||
renderInput(prefixCls, { addonBefore, addonAfter }) {
|
||||
const otherProps = omit(this.$props, [
|
||||
'prefixCls',
|
||||
'onPressEnter',
|
||||
'addonBefore',
|
||||
'addonAfter',
|
||||
'prefix',
|
||||
|
@ -185,7 +186,7 @@ export default {
|
|||
// https://github.com/vueComponent/ant-design-vue/issues/2203
|
||||
if (((e.isComposing || composing) && this.lazy) || this.stateValue === value) return;
|
||||
this.setValue(value, this.clearPasswordValueAttribute);
|
||||
resolveOnChange(this.input, e, this.onChange);
|
||||
resolveOnChange(this.input, e, this.triggerChange);
|
||||
},
|
||||
handleKeyDown(e) {
|
||||
if (e.keyCode === 13) {
|
||||
|
|
|
@ -8,6 +8,7 @@ import BaseMixin from '../_util/BaseMixin';
|
|||
import inputProps from './inputProps';
|
||||
import PropTypes from '../_util/vue-types';
|
||||
import { getOptionProps } from '../_util/props-util';
|
||||
import syncWatch from '../_util/syncWatch';
|
||||
|
||||
const RESIZE_STATUS_NONE = 0;
|
||||
const RESIZE_STATUS_RESIZING = 1;
|
||||
|
@ -17,6 +18,7 @@ const TextAreaProps = {
|
|||
...inputProps,
|
||||
autosize: PropTypes.oneOfType([Object, Boolean]),
|
||||
autoSize: PropTypes.oneOfType([Object, Boolean]),
|
||||
onResize: PropTypes.func,
|
||||
};
|
||||
const ResizableTextArea = {
|
||||
name: 'ResizableTextArea',
|
||||
|
@ -37,11 +39,11 @@ const ResizableTextArea = {
|
|||
raf.cancel(this.resizeFrameId);
|
||||
},
|
||||
watch: {
|
||||
value() {
|
||||
value: syncWatch(function() {
|
||||
this.$nextTick(() => {
|
||||
this.resizeTextarea();
|
||||
});
|
||||
},
|
||||
}),
|
||||
},
|
||||
methods: {
|
||||
saveTextArea(textArea) {
|
||||
|
|
|
@ -19,6 +19,7 @@ export default {
|
|||
...inputProps,
|
||||
// 不能设置默认值 https://github.com/vueComponent/ant-design-vue/issues/1916
|
||||
enterButton: PropTypes.any,
|
||||
onSearch: PropTypes.func,
|
||||
},
|
||||
setup() {
|
||||
return {
|
||||
|
@ -29,13 +30,14 @@ export default {
|
|||
saveInput(node) {
|
||||
this.input = node;
|
||||
},
|
||||
onChange(e) {
|
||||
handleChange(e) {
|
||||
if (e && e.target && e.type === 'click') {
|
||||
this.$emit('search', e.target.value, e);
|
||||
}
|
||||
this.$emit('update:value', e.target.value);
|
||||
this.$emit('change', e);
|
||||
},
|
||||
onSearch(e) {
|
||||
handleSearch(e) {
|
||||
if (this.loading || this.disabled) {
|
||||
return;
|
||||
}
|
||||
|
@ -78,7 +80,7 @@ export default {
|
|||
if (enterButton) return suffix;
|
||||
|
||||
const icon = (
|
||||
<SearchOutlined class={`${prefixCls}-icon`} key="searchIcon" onClick={this.onSearch} />
|
||||
<SearchOutlined class={`${prefixCls}-icon`} key="searchIcon" onClick={this.handleSearch} />
|
||||
);
|
||||
|
||||
if (suffix) {
|
||||
|
@ -114,7 +116,7 @@ export default {
|
|||
key: 'enterButton',
|
||||
class: isAntdButton ? btnClassName : '',
|
||||
...(isAntdButton ? { size } : {}),
|
||||
onClick: this.onSearch,
|
||||
onClick: this.handleSearch,
|
||||
});
|
||||
} else {
|
||||
button = (
|
||||
|
@ -124,7 +126,7 @@ export default {
|
|||
size={size}
|
||||
disabled={disabled}
|
||||
key="enterButton"
|
||||
onClick={this.onSearch}
|
||||
onClick={this.handleSearch}
|
||||
>
|
||||
{enterButton === true || enterButton === '' ? <SearchOutlined /> : enterButton}
|
||||
</Button>
|
||||
|
@ -149,6 +151,7 @@ export default {
|
|||
delete restProps.loading;
|
||||
delete restProps.enterButton;
|
||||
delete restProps.addonBefore;
|
||||
delete restProps['onUpdate:value'];
|
||||
const getPrefixCls = this.configProvider.getPrefixCls;
|
||||
const prefixCls = getPrefixCls('input-search', customizePrefixCls);
|
||||
const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls);
|
||||
|
@ -175,8 +178,8 @@ export default {
|
|||
addonAfter: this.renderAddonAfter(prefixCls),
|
||||
addonBefore,
|
||||
class: inputClassName,
|
||||
onPressEnter: this.onSearch,
|
||||
onChange: this.onChange,
|
||||
onPressEnter: this.handleSearch,
|
||||
onChange: this.handleChange,
|
||||
};
|
||||
return <Input {...inputProps} ref={this.saveInput} />;
|
||||
},
|
||||
|
|
|
@ -41,12 +41,12 @@ export default {
|
|||
setValue(value, callback) {
|
||||
if (!hasProp(this, 'value')) {
|
||||
this.stateValue = value;
|
||||
this.$nextTick(() => {
|
||||
callback && callback();
|
||||
});
|
||||
} else {
|
||||
this.$forceUpdate();
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
callback && callback();
|
||||
});
|
||||
},
|
||||
handleKeyDown(e) {
|
||||
if (e.keyCode === 13) {
|
||||
|
@ -54,7 +54,7 @@ export default {
|
|||
}
|
||||
this.$emit('keydown', e);
|
||||
},
|
||||
onChange(e) {
|
||||
triggerChange(e) {
|
||||
this.$emit('update:value', e.target.value);
|
||||
this.$emit('change', e);
|
||||
this.$emit('input', e);
|
||||
|
@ -66,7 +66,7 @@ export default {
|
|||
this.setValue(e.target.value, () => {
|
||||
this.resizableTextArea.resizeTextarea();
|
||||
});
|
||||
resolveOnChange(this.resizableTextArea.textArea, e, this.onChange);
|
||||
resolveOnChange(this.resizableTextArea.textArea, e, this.triggerChange);
|
||||
},
|
||||
|
||||
focus() {
|
||||
|
@ -88,7 +88,7 @@ export default {
|
|||
this.resizableTextArea.renderTextArea();
|
||||
this.focus();
|
||||
});
|
||||
resolveOnChange(this.resizableTextArea.textArea, e, this.onChange);
|
||||
resolveOnChange(this.resizableTextArea.textArea, e, this.triggerChange);
|
||||
},
|
||||
|
||||
renderTextArea(prefixCls) {
|
||||
|
|
|
@ -32,4 +32,12 @@ export default {
|
|||
},
|
||||
maxlength: PropTypes.number,
|
||||
loading: PropTypes.bool,
|
||||
onPressEnter: PropTypes.func,
|
||||
onKeydown: PropTypes.func,
|
||||
onKeyup: PropTypes.func,
|
||||
onFocus: PropTypes.func,
|
||||
onBlur: PropTypes.func,
|
||||
onChange: PropTypes.func,
|
||||
onInput: PropTypes.func,
|
||||
'onUpdate:value': PropTypes.func,
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import demo from '../antdv-demo/docs/grid/demo/index';
|
||||
import demo from '../antdv-demo/docs/input/demo/index';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
|
Loading…
Reference in New Issue