mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-09 02:49:18 +08:00
fix(Input.OTP): Continuous deletion is not allowed. (#54850)
Co-authored-by: liuqiang <qiang.liu@xinjifamily.com>
This commit is contained in:
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user