From 31c8339315a2e65fef821fa71b98f00ad938b154 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Thu, 16 Dec 2021 09:36:27 +0800 Subject: [PATCH] fix: remove textarea maxlength support emoji --- components/input/Input.tsx | 159 ------------------ components/input/ResizableTextArea.tsx | 1 + .../__tests__/__snapshots__/demo.test.js.snap | 2 +- .../__snapshots__/index.test.js.snap | 4 +- 4 files changed, 4 insertions(+), 162 deletions(-) diff --git a/components/input/Input.tsx b/components/input/Input.tsx index 5a19a7c22..0239b4755 100644 --- a/components/input/Input.tsx +++ b/components/input/Input.tsx @@ -347,163 +347,4 @@ export default defineComponent({ ); }; }, - - // methods: { - // handleInputFocus(e: Event) { - // this.isFocused = true; - // this.onFocus && this.onFocus(e); - // }, - - // handleInputBlur(e: Event) { - // this.isFocused = false; - // this.onBlur && this.onBlur(e); - // this.formItemContext.onFieldBlur(); - // }, - - // focus() { - // this.input.focus(); - // }, - - // blur() { - // this.input.blur(); - // }, - // select() { - // this.input.select(); - // }, - - // saveClearableInput(input: HTMLInputElement) { - // this.clearableInput = input; - // }, - - // saveInput(input: HTMLInputElement) { - // this.input = input; - // }, - - // setValue(value: string | number, callback?: Function) { - // if (this.stateValue === value) { - // return; - // } - // if (!hasProp(this, 'value')) { - // this.stateValue = value; - // } else { - // (this as any).$forceUpdate(); - // } - // nextTick(() => { - // callback && callback(); - // }); - // }, - // triggerChange(e: Event) { - // this.$emit('update:value', (e.target as HTMLInputElement).value); - // this.$emit('change', e); - // this.$emit('input', e); - // this.formItemContext.onFieldChange(); - // }, - // handleReset(e: Event) { - // this.setValue('', () => { - // this.focus(); - // }); - // resolveOnChange(this.input, e, this.triggerChange); - // }, - // renderInput(prefixCls: string, { addonBefore, addonAfter }) { - // const otherProps = omit(this.$props, [ - // 'prefixCls', - // 'onPressEnter', - // 'addonBefore', - // 'addonAfter', - // 'prefix', - // 'suffix', - // 'allowClear', - // 'defaultValue', - // 'lazy', - // 'size', - // 'inputPrefixCls', - // 'loading', - // ]); - // const { - // handleKeyDown, - // handleChange, - // handleInputFocus, - // handleInputBlur, - // size, - // disabled, - // valueModifiers = {}, - // $attrs, - // } = this; - // const inputProps: any = { - // ...otherProps, - // ...$attrs, - // id: otherProps.id ?? this.formItemContext.id.value, - // onKeydown: handleKeyDown, - // class: classNames(getInputClassName(prefixCls, size, disabled), { - // [$attrs.class as string]: $attrs.class && !addonBefore && !addonAfter, - // }), - // ref: this.saveInput, - // key: 'ant-input', - // onInput: handleChange, - // onChange: handleChange, - // onFocus: handleInputFocus, - // onBlur: handleInputBlur, - // }; - // if (valueModifiers.lazy) { - // delete inputProps.onInput; - // } - // if (!inputProps.autofocus) { - // delete inputProps.autofocus; - // } - // const inputNode = ; - // return withDirectives(inputNode as VNode, [[antInputDirective]]); - // }, - // clearPasswordValueAttribute() { - // // https://github.com/ant-design/ant-design/issues/20541 - // this.removePasswordTimeout = setTimeout(() => { - // if ( - // this.input && - // this.input.getAttribute && - // this.input.getAttribute('type') === 'password' && - // this.input.hasAttribute('value') - // ) { - // this.input.removeAttribute('value'); - // } - // }); - // }, - // handleChange(e: Event) { - // const { value, composing, isComposing } = e.target as any; - // // https://github.com/vueComponent/ant-design-vue/issues/2203 - // if (((isComposing || composing) && this.lazy) || this.stateValue === value) return; - // this.setValue(value, this.clearPasswordValueAttribute); - // resolveOnChange(this.input, e, this.triggerChange); - // }, - // handleKeyDown(e: KeyboardEvent) { - // if (e.keyCode === 13) { - // this.$emit('pressEnter', e); - // } - // this.$emit('keydown', e); - // }, - // }, - // render() { - // const { prefixCls: customizePrefixCls } = this.$props; - // const { stateValue, isFocused } = this.$data; - // const getPrefixCls = this.configProvider.getPrefixCls; - // const prefixCls = getPrefixCls('input', customizePrefixCls); - // const addonAfter = getComponent(this, 'addonAfter'); - // const addonBefore = getComponent(this, 'addonBefore'); - // const suffix = getComponent(this, 'suffix'); - // const prefix = getComponent(this, 'prefix'); - // const props: any = { - // ...this.$attrs, - // ...getOptionProps(this), - // prefixCls, - // inputType: 'input', - // value: fixControlledValue(stateValue), - // element: this.renderInput(prefixCls, { addonAfter, addonBefore }), - // handleReset: this.handleReset, - // addonAfter, - // addonBefore, - // suffix, - // prefix, - // isFocused, - // }; - - // return ; - // }, }); diff --git a/components/input/ResizableTextArea.tsx b/components/input/ResizableTextArea.tsx index edd96084c..a12d540b1 100644 --- a/components/input/ResizableTextArea.tsx +++ b/components/input/ResizableTextArea.tsx @@ -104,6 +104,7 @@ const ResizableTextArea = defineComponent({ 'allowClear', 'type', 'lazy', + 'maxlength', ]); const cls = classNames(prefixCls, attrs.class, { [`${prefixCls}-disabled`]: disabled, diff --git a/components/input/__tests__/__snapshots__/demo.test.js.snap b/components/input/__tests__/__snapshots__/demo.test.js.snap index c4b029cf3..3b3feceb7 100644 --- a/components/input/__tests__/__snapshots__/demo.test.js.snap +++ b/components/input/__tests__/__snapshots__/demo.test.js.snap @@ -88,7 +88,7 @@ exports[`renders ./components/input/demo/search-input.vue correctly 1`] = `
exports[`renders ./components/input/demo/search-input-loading.vue correctly 1`] = `


`; -exports[`renders ./components/input/demo/show-count.vue correctly 1`] = `
`; +exports[`renders ./components/input/demo/show-count.vue correctly 1`] = `
`; exports[`renders ./components/input/demo/size.vue correctly 1`] = `
`; diff --git a/components/input/__tests__/__snapshots__/index.test.js.snap b/components/input/__tests__/__snapshots__/index.test.js.snap index 5d40d9895..a44194541 100644 --- a/components/input/__tests__/__snapshots__/index.test.js.snap +++ b/components/input/__tests__/__snapshots__/index.test.js.snap @@ -6,6 +6,6 @@ exports[`Input.Search should support suffix 1`] = ``; -exports[`TextArea should support maxlength 1`] = ``; +exports[`TextArea should support maxlength 1`] = ``; -exports[`TextArea should support showCount 1`] = `
`; +exports[`TextArea should support showCount 1`] = `
`;