fix(Input.OTP): Continuous deletion is not allowed. (#54850)

Co-authored-by: liuqiang <qiang.liu@xinjifamily.com>
This commit is contained in:
ug
2025-09-04 09:43:54 +08:00
committed by GitHub
parent 71b53a0db3
commit 4d295e20db

View File

@@ -50,13 +50,7 @@ const OTPInput = React.forwardRef<InputRef, OTPInputProps>((props, ref) => {
onActiveChange(index + 1);
} else if (key === 'z' && (ctrlKey || metaKey)) {
event.preventDefault();
}
syncSelection();
};
const onInternalKeyUp: React.KeyboardEventHandler<HTMLInputElement> = (e) => {
if (e.key === 'Backspace' && !value) {
} else if (key === 'Backspace' && !value) {
onActiveChange(index - 1);
}
@@ -82,7 +76,6 @@ const OTPInput = React.forwardRef<InputRef, OTPInputProps>((props, ref) => {
onInput={onInternalChange}
onFocus={syncSelection}
onKeyDown={onInternalKeyDown}
onKeyUp={onInternalKeyUp}
onMouseDown={syncSelection}
onMouseUp={syncSelection}
className={classNames(className, {