Browse Source

fix: remove textarea maxlength support emoji

pull/5043/head^2
tangjinzhou 3 years ago
parent
commit
31c8339315
  1. 159
      components/input/Input.tsx
  2. 1
      components/input/ResizableTextArea.tsx
  3. 2
      components/input/__tests__/__snapshots__/demo.test.js.snap
  4. 4
      components/input/__tests__/__snapshots__/index.test.js.snap

159
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 = <input {...inputProps} />;
// 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 <ClearableLabeledInput {...props} ref={this.saveClearableInput} />;
// },
});

1
components/input/ResizableTextArea.tsx

@ -104,6 +104,7 @@ const ResizableTextArea = defineComponent({
'allowClear',
'type',
'lazy',
'maxlength',
]);
const cls = classNames(prefixCls, attrs.class, {
[`${prefixCls}-disabled`]: disabled,

2
components/input/__tests__/__snapshots__/demo.test.js.snap

@ -88,7 +88,7 @@ exports[`renders ./components/input/demo/search-input.vue correctly 1`] = `<div>
exports[`renders ./components/input/demo/search-input-loading.vue correctly 1`] = `<div><span class="ant-input-group-wrapper ant-input-search"><span class="ant-input-wrapper ant-input-group"><!----><input placeholder="input search loading deault" type="text" class="ant-input"><span class="ant-input-group-addon"><button class="ant-btn ant-btn-loading ant-input-search-button ant-btn-icon-only" type="button"><span role="img" aria-label="loading" class="anticon anticon-loading"><svg focusable="false" class="anticon-spin" data-icon="loading" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="0 0 1024 1024"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg></span></button></span></span></span><br><br><span class="ant-input-group-wrapper ant-input-search ant-input-search-with-button"><span class="ant-input-wrapper ant-input-group"><!----><input placeholder="input search loading with enterButton" type="text" class="ant-input"><span class="ant-input-group-addon"><button class="ant-btn ant-btn-primary ant-btn-loading ant-input-search-button" type="button"><span role="img" aria-label="loading" class="anticon anticon-loading"><svg focusable="false" class="anticon-spin" data-icon="loading" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="0 0 1024 1024"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg></span><span role="img" aria-label="search" class="anticon anticon-search"><svg focusable="false" class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span></button></span></span></span></div>`;
exports[`renders ./components/input/demo/show-count.vue correctly 1`] = `<div class="ant-input-textarea ant-input-textarea-show-count" data-count="10 / 100"><textarea maxlength="100" class="ant-input"></textarea></div>`;
exports[`renders ./components/input/demo/show-count.vue correctly 1`] = `<div class="ant-input-textarea ant-input-textarea-show-count" data-count="10 / 100"><textarea class="ant-input"></textarea></div>`;
exports[`renders ./components/input/demo/size.vue correctly 1`] = `<div class="components-input-demo-size"><input placeholder="large size" type="text" class="ant-input ant-input-lg"><input placeholder="default size" type="text" class="ant-input"><input placeholder="small size" type="text" class="ant-input ant-input-sm"></div>`;

4
components/input/__tests__/__snapshots__/index.test.js.snap

@ -6,6 +6,6 @@ exports[`Input.Search should support suffix 1`] = `<span class="ant-input-group-
exports[`TextArea should support disabled 1`] = `<textarea disabled="" class="ant-input ant-input-disabled"></textarea>`;
exports[`TextArea should support maxlength 1`] = `<textarea maxlength="10" class="ant-input"></textarea>`;
exports[`TextArea should support maxlength 1`] = `<textarea class="ant-input"></textarea>`;
exports[`TextArea should support showCount 1`] = `<div class="ant-input-textarea ant-input-textarea-show-count" data-count="3 / 10"><textarea maxlength="10" class="ant-input"></textarea></div>`;
exports[`TextArea should support showCount 1`] = `<div class="ant-input-textarea ant-input-textarea-show-count" data-count="3 / 10"><textarea class="ant-input"></textarea></div>`;

Loading…
Cancel
Save