fix:修复input-email配置clearable,清空内容报错问题 (#3886)

Co-authored-by: Qin,Haoyan <qinhaoyan@baidu.com>
This commit is contained in:
qinhaoyan 2022-03-29 15:18:48 +08:00 committed by GitHub
parent bf5c51712a
commit 3bea44c9e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -235,7 +235,16 @@ export default class TextControl extends React.PureComponent<
// 光标放到最后
const len = this.input.value.length;
len && this.input.setSelectionRange(len, len);
if (len) {
// type为email的input元素不支持setSelectionRange先改为text
if (this.input.type === 'email') {
this.input.type = 'text';
this.input.setSelectionRange(len, len);
this.input.type = 'email';
} else {
this.input.setSelectionRange(len, len);
}
}
}
clearValue() {