mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 08:21:46 +03:00
fix: can not limit Chinese input lenth correctly (#947)
This commit is contained in:
parent
7890219e29
commit
cb118149f3
@ -19,7 +19,6 @@ type inputProps = {
|
|||||||
onBlur?: FocusEventHandler<HTMLInputElement>;
|
onBlur?: FocusEventHandler<HTMLInputElement>;
|
||||||
onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
|
onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Input = (props: inputProps) => {
|
export const Input = (props: inputProps) => {
|
||||||
const {
|
const {
|
||||||
disabled,
|
disabled,
|
||||||
@ -35,15 +34,11 @@ export const Input = (props: inputProps) => {
|
|||||||
} = props;
|
} = props;
|
||||||
const [value, setValue] = useState<string>(valueProp || '');
|
const [value, setValue] = useState<string>(valueProp || '');
|
||||||
const handleChange: InputHTMLAttributes<HTMLInputElement>['onChange'] = e => {
|
const handleChange: InputHTMLAttributes<HTMLInputElement>['onChange'] = e => {
|
||||||
if (
|
const { value } = e.target;
|
||||||
(maxLength && e.target.value.length > maxLength) ||
|
setValue(value);
|
||||||
(minLength && e.target.value.length < minLength)
|
onChange && onChange(value);
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setValue(e.target.value);
|
|
||||||
onChange && onChange(e.target.value);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleBlur: InputHTMLAttributes<HTMLInputElement>['onBlur'] = e => {
|
const handleBlur: InputHTMLAttributes<HTMLInputElement>['onBlur'] = e => {
|
||||||
onBlur && onBlur(e);
|
onBlur && onBlur(e);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user